Skip to content

Commit 7e11152

Browse files
committed
don't focus on active tab
ant-design/ant-design#22337
1 parent b3be0b0 commit 7e11152

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/TabBarRootNode.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ import classnames from 'classnames';
33
import { getDataAttr } from './utils';
44

55
export default class TabBarRootNode extends React.Component {
6-
componentDidUpdate() {
7-
const activeTab = this.props.getRef('activeTab');
8-
if (activeTab) {
9-
activeTab.focus();
10-
}
11-
}
12-
136
getExtraContentStyle = () => {
147
const { tabBarPosition, direction } = this.props;
158
const topOrBottom = tabBarPosition === 'top' || tabBarPosition === 'bottom';

tests/a11y.spec.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ describe('<TabsComponent />', () => {
6666
which: KeyCode.RIGHT,
6767
});
6868
expect(tabs.at(0).getDOMNode().className).toContain('rc-tabs-tab-active');
69-
expect(tabs.at(1).getDOMNode().className).not.toContain('rc-tabs-tab-active');
7069
});
7170

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

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

84-
it('clicking a tab should move focus to this tab', () => {
85-
const thirdTab = tabs.at(2);
86-
thirdTab.simulate('click');
87-
expect(document.activeElement).toBe(thirdTab.getDOMNode());
82+
it('clicking a tab should active this tab', () => {
83+
tabs.at(2).simulate('click');
84+
expect(tabs.at(2).getDOMNode().className).toContain('rc-tabs-tab-active');
8885
});
8986
});
9087

0 commit comments

Comments
 (0)