Why the active tab panel has tabindex="0"?
See original GitHub issue❓Question
I have a set of tabs and a set of corresponding tab panels. As in your basic example. I noticed that the active tab panel has tabindex="0"
attribute. Why is this needed? This makes the active panel tabbable. So when I use tabs inside a dialog along with a focus lock that lets me tab through all the controls in the dialog, the active panel receives its own focus before all the controls in it, as I tab through the dialog. Is there a way to fix that? I use the same react-focus-lock
library that you use internally, if this matters.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
ARIA: tab role - Accessibility - MDN Web Docs - Mozilla
All of the tabpanel elements have tabindex="0" to make them tabbable, and all but the currently active one have the hidden attribute.
Read more >Keyboard Accessibility - Tabindex - WebAIM
tabindex="0" allows elements besides links and form elements to receive keyboard focus. It does not change the tab order, but places the element ......
Read more >Control focus with tabindex - web.dev
Using a tabindex greater than 0 is considered an anti-pattern because screen readers navigate the page in DOM order, not tab order. If...
Read more >How and when to use the tabindex attribute - bitsofcode
A tabindex of zero is typically used either to add focus back to elements that it was programatically removed from. Another good use...
Read more >How-to: Use the tabindex attribute - The A11Y Project
When tabindex 's value is set to zero or a positive number, the element can be navigated to via the keyboard's Tab key....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@coreylight If you pass
tabIndex
to the panel it will override what we set internally. If you passnull
it will remove the tabIndex altogether (TypeScript will complain, but you can cast as any or ignore the line if you’d like).I don’t think this is a great idea because of the aforementioned accessibility requirements. Another option would be to use
onFocus
andonPointerDown
to figure out if the user is interacting with the scroller and, if so, re-focusing the input in that case. This is similar to how we manage focus in combobox when the user interacts with options in the popover.I had this question as well, why tab panels are a tab target. In a normal document flow, static content does not receive focus, and pressing tab jumps from one interactive element to another. I’m trying to learn more about accessibility, and am not proficient with assistive technologies. Is the reason the panel should be a target because it might have been hidden when the page first loaded, and therefore the tech won’t necessarily know it’s there unless it gets focus?