Skip to content

Commit

Permalink
don't focus on active tab
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Mar 18, 2020
1 parent b3be0b0 commit 7e11152
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/TabBarRootNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import classnames from 'classnames';
import { getDataAttr } from './utils';

export default class TabBarRootNode extends React.Component {
componentDidUpdate() {
const activeTab = this.props.getRef('activeTab');
if (activeTab) {
activeTab.focus();
}
}

getExtraContentStyle = () => {
const { tabBarPosition, direction } = this.props;
const topOrBottom = tabBarPosition === 'top' || tabBarPosition === 'bottom';
Expand Down
13 changes: 5 additions & 8 deletions tests/a11y.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ describe('<TabsComponent />', () => {
which: KeyCode.RIGHT,
});
expect(tabs.at(0).getDOMNode().className).toContain('rc-tabs-tab-active');
expect(tabs.at(1).getDOMNode().className).not.toContain('rc-tabs-tab-active');
});

it('first tab should be selected by default', () => {
Expand All @@ -75,16 +74,14 @@ describe('<TabsComponent />', () => {
expect(selectedTab.getDOMNode()).toBe(firstTab.getDOMNode());
});

it('switching tab via keyboard arrow navigation should move focus to new active tab', () => {
it('switching tab via keyboard arrow navigation should move to new active tab', () => {
simulateKeyDown(tabList.getDOMNode(), KeyCode.RIGHT);
const secondTab = tabs.at(1);
expect(document.activeElement).toBe(secondTab.getDOMNode());
expect(tabs.at(1).getDOMNode().className).toContain('rc-tabs-tab-active');
});

it('clicking a tab should move focus to this tab', () => {
const thirdTab = tabs.at(2);
thirdTab.simulate('click');
expect(document.activeElement).toBe(thirdTab.getDOMNode());
it('clicking a tab should active this tab', () => {
tabs.at(2).simulate('click');
expect(tabs.at(2).getDOMNode().className).toContain('rc-tabs-tab-active');
});
});

Expand Down

0 comments on commit 7e11152

Please sign in to comment.