bug(react/a11y): Tabs primitive uses malformed id values with spaces in them #5220
Closed
4 tasks done
Labels
accessibility
Bugs or features related to accessibility
bug
Something isn't working
good first issue
Good for newcomers
Primitive
An issue or a feature-request for one or more UI Primitive
React
An issue or a feature-request for React platform
Before creating a new issue, please confirm:
On which framework/platform are you having an issue?
React
Which UI component?
Primitive components
How is your app built?
Next.js
What browsers are you seeing the problem on?
No response
Which region are you seeing the problem in?
No response
Please describe your bug.
The Tabs primitive generates
id
s with spaces in them.The tabs primitive generates
id
attributes for the TabsPanel and TabsItems elements using thevalue
prop which is the name of the Tab. This leads to the following markup (using the docs demo example): Note that theid
for the button has a space in it as does theid
it references in thearia-controls
. Similarly, theid
andaria-labelledby
attributes have spaces in their values as well.This can cause issues for assistive tech because then the tabs aren't properly associated to each other, and just generally other issues because they are not valid IDs that can be used with other javascript or CSS correctly. For example you can see in the accessibility tab for this tab panel that it can't find the correct element that aria-labelledby references so instead uses "First":
You could probably:
id={
${value.trim()}-tab}
(just ok)id
for eachitem
usingReact.useId()
to ensure each Tabs usage has unique ids for it's tab elements (probably better than using just the name of the tab)What's the expected behaviour?
Tabs
id
s don't have spaces in them and tabs are programmatically linked to each other correctlyHelp us reproduce the bug!
Inspect the markup for Tabs on https://ui.docs.amplify.aws/react/components/tabs
Code Snippet
// Put your code below this line.
Console log output
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: