Skip to content

Commit

Permalink
fix(tab): add aria-disabled depending on disabled prop (#4698)
Browse files Browse the repository at this point in the history
  • Loading branch information
abbeyhrt authored and asudoh committed Nov 18, 2019
1 parent fd36c94 commit 79be49d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/react/src/components/Tab/Tab-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ describe('Tab', () => {
);
});

it('has aria-disabled that matches disabled', () => {
const getDisabledRegion = () => wrapper.find('[aria-disabled]');

expect(getDisabledRegion().length).toEqual(0);

wrapper.setProps({ disabled: true });
expect(getDisabledRegion().prop('aria-disabled')).toEqual(true);
});

it(`adds [className="${prefix}--tabs__nav-item--selected"] when selected prop is true`, () => {
wrapper.setProps({ selected: true });
expect(wrapper.hasClass(`${prefix}--tabs__nav-item--selected`)).toBe(
Expand Down Expand Up @@ -110,6 +119,7 @@ describe('Tab', () => {
});
});
});

describe('custom render label', () => {
const wrapper = mount(
<Tab
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/Tab/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export default class Tab extends React.Component {
role: 'tab',
tabIndex: !disabled ? tabIndex : -1,
['aria-selected']: selected,
['aria-disabled']: disabled,
ref: e => {
this.tabAnchor = e;
},
Expand Down

0 comments on commit 79be49d

Please sign in to comment.