Skip to content

Commit

Permalink
fix(tab): Set initial tabIndex state to -1 (#690) (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben McKernan authored and Matt Goo committed Mar 18, 2019
1 parent 52eeb52 commit 9034c98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/tab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export default class Tab extends React.Component<TabProps, TabState> {
'aria-selected': false,
'activateIndicator': false,
'previousIndicatorClientRect': this.props.previousIndicatorClientRect,
'tabIndex': -1,
};

componentDidMount() {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/tab/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ test('adds the active class if props.active is true on mount', () => {
assert.isTrue(wrapper.hasClass('mdc-tab--active'));
});

test('sets the tabIndex to 0 if props.active is true on mount', () => {
const wrapper = shallow(<Tab active />);
assert.equal(wrapper.prop('tabIndex'), 0);
});

test('sets the tabIndex to -1 if props.active is false on mount', () => {
const wrapper = shallow(<Tab active={false} />);
assert.equal(wrapper.prop('tabIndex'), -1);
});

test('adds a class from state.classList', () => {
const wrapper = shallow(<Tab />);
wrapper.setState({classList: new Set(['test-class'])});
Expand Down

0 comments on commit 9034c98

Please sign in to comment.