Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

Commit ab434fd

Browse files
Ben McKernanMatt Goo
authored andcommitted
fix(tab): Set initial tabIndex state to -1 (#690) (#691)
1 parent 52eeb52 commit ab434fd

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/tab/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export default class Tab extends React.Component<TabProps, TabState> {
7272
'aria-selected': false,
7373
'activateIndicator': false,
7474
'previousIndicatorClientRect': this.props.previousIndicatorClientRect,
75+
'tabIndex': -1,
7576
};
7677

7778
componentDidMount() {

test/unit/tab/index.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ test('adds the active class if props.active is true on mount', () => {
2929
assert.isTrue(wrapper.hasClass('mdc-tab--active'));
3030
});
3131

32+
test('sets the tabIndex to 0 if props.active is true on mount', () => {
33+
const wrapper = shallow(<Tab active />);
34+
assert.equal(wrapper.prop('tabIndex'), 0);
35+
});
36+
37+
test('sets the tabIndex to -1 if props.active is false on mount', () => {
38+
const wrapper = shallow(<Tab active={false} />);
39+
assert.equal(wrapper.prop('tabIndex'), -1);
40+
});
41+
3242
test('adds a class from state.classList', () => {
3343
const wrapper = shallow(<Tab />);
3444
wrapper.setState({classList: new Set(['test-class'])});

0 commit comments

Comments
 (0)