react-tabs icon indicating copy to clipboard operation
react-tabs copied to clipboard

[Bug] Children with aria role="tab" cause parent tabs to reset

Open hailwood opened this issue 4 years ago • 3 comments

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.

hailwood avatar Oct 14 '20 21:10 hailwood

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

lauriejones avatar Nov 19 '20 04:11 lauriejones

image

SaayanBiswas98 avatar May 25 '23 07:05 SaayanBiswas98

<Collapse accordion={false}> this will not reset the tabs

SaayanBiswas98 avatar May 25 '23 07:05 SaayanBiswas98