react-tabs
react-tabs copied to clipboard
[Bug] Children with aria role="tab" cause parent tabs to reset
Simple Reproduction here https://codesandbox.io/s/crimson-sun-wrp0w
I was trying to use rc-collapse which is an accessible collapse component, when you have the accordion mode enabled then it correctly sets the components to have the aria-roles to tablist/tab/tabpanel unfortunately this causes the react-tabs component to think that clicks to open the accordion are a trigger for the tabs.
We were having the exact same issue. Our accordion component when used within tabs would break as this package assumed all role="tab*"
attributes were for it.
A surprisingly small fix we were able to make was to add a data-tabs
attribute to our Accordion component to make use of this functionality:
https://github.com/reactjs/react-tabs/blob/a37ca85f8dc7caa1def5805f6fdaa1653c1e0cd1/src/components/UncontrolledTabs.js#L318-L339
<Collapse accordion={false}> this will not reset the tabs