Skip to content

Commit d6a36a9

Browse files
authored
fix(Tab): hoist tab role to upper element (#5173)
This change hoists `tab` role and its associated ARIA attributes from `<a>` to `<li>`, given putting `tab` role to `<a>` makes VoiceOver think it's a single tab in a container. No new DAP error is observed by this change. Fixes #5083.
1 parent c5fddd1 commit d6a36a9

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

packages/react/src/components/Tab/Tab-test.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@ describe('Tab', () => {
2727
);
2828
});
2929

30-
it('renders <li> with [role="presentation"]', () => {
31-
expect(wrapper.props().role).toEqual('presentation');
32-
});
33-
34-
it('renders <a> with [role="tab"]', () => {
35-
expect(wrapper.find('a').props().role).toEqual('tab');
30+
it('renders <li> with [role="tab"]', () => {
31+
expect(wrapper.props().role).toEqual('tab');
3632
});
3733

3834
it('renders <a> with tabindex set to 0', () => {

packages/react/src/components/Tab/Tab.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ export default class Tab extends React.Component {
135135
id,
136136
className: `${prefix}--tabs__nav-link`,
137137
href,
138-
role: 'tab',
139138
tabIndex: !disabled ? tabIndex : -1,
140-
['aria-selected']: selected,
141-
['aria-disabled']: disabled,
142-
['aria-controls']: id && `${id}__panel`,
143139
ref: e => {
144140
this.tabAnchor = e;
145141
},
@@ -164,8 +160,10 @@ export default class Tab extends React.Component {
164160
handleTabKeyDown(index, evt);
165161
onKeyDown(evt);
166162
}}
167-
role="presentation"
168-
selected={selected}>
163+
role="tab"
164+
aria-selected={selected}
165+
aria-disabled={disabled}
166+
aria-controls={`${id}__panel`}>
169167
{renderAnchor ? (
170168
renderAnchor(anchorProps)
171169
) : (

0 commit comments

Comments
 (0)