Description
Provide a general summary of the issue here
When rendering the <TabPanel>
components before the <TabList>
, the ID's of the TabPanel
mismatch the aria-controls
properties of the Tab
's, because they don't receive the Tabs identifier as part of the ID.
Instead, it passes undefined-tabpanel-*
as the id
and undefined-tab-*
as the aria-labelledby
on the tab panels.
Users can still interact with the tabs, so the issue is hard to spot, but it will result in incorrect aria references.
It seems like currently useTabsPanel
depends on the TabListState
here:
🤔 Expected Behavior?
Not sure if the strict order of the components is expected behavior, but I'd expect the "tabs identifier" to be generated in the parent Tabs
component and passed down to both the TabPanels and the TabList, so that the order doesn't really matter.
If it is expected to have this strict order, I'd expect some kind of notification (e.g. a console warning) saying the order is incorrect.
😯 Current Behavior
So the following example results in the correct state:
<Tabs>
<TabList aria-label="History of Ancient Rome">
<Tab id="FoR">Founding of Rome</Tab>
<Tab id="MaR">Monarchy and Republic</Tab>
</TabList>
<TabPanel id="FoR">Arma virumque cano, Troiae qui primus ab oris.</TabPanel>
<TabPanel id="MaR">Senatus Populusque Romanus.</TabPanel>
</Tabs>
while the following example will result in an incorrect state:
<Tabs>
<TabPanel id="FoR">Arma virumque cano, Troiae qui primus ab oris.</TabPanel>
<TabPanel id="MaR">Senatus Populusque Romanus.</TabPanel>
<TabList aria-label="History of Ancient Rome">
<Tab id="FoR">Founding of Rome</Tab>
<Tab id="MaR">Monarchy and Republic</Tab>
</TabList>
</Tabs>
💁 Possible Solution
No response
🔦 Context
No response
🖥️ Steps to Reproduce
See a reproduction here: https://codesandbox.io/p/devbox/quirky-cloud-yxs4vl. The tab panel elements receive id="undefined-tabpanel-FoR" aria-labelledby="undefined-tab-FoR"
Version
react-aria-components@v1.10.1
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
MacOS
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response