-
Notifications
You must be signed in to change notification settings - Fork 84
Description
Hello,
I would like to report some side-effects on the Tabs component after the PR #152.
- left and right arrow key interactions
Suppose there are 4 tabs. At first when the selectedTabIndex = 0, right key takes us to the 3rd tab. For some reason, it skips the 2nd one (I tried looking at the code but couldn't find a reason behind this behaviour). And then it stays stuck in the 3rd because the selectedTabIndex is never updated.
Same thing with the left key. When selectedTabIndex = 0, the left key takes us to the second-last tab, again skipping one tab.
- focus in useEffect
As there's a focus in a useEffect, as soon as the page loads, the selected tab is being focused. This is not really an expected behaviour because there can be other content before the Tabs comp. in a page.
Code to add in the vite example provided in this repo to reproduce the mentioned behaviour:
function TabsExample ( ){
return (
<Tabs
tabs={[
{
label: "Métadonnées",
content: <p>...liste de métadonnées...</p>,
},
{
label: "Jeux de données",
content: <p>...liste de jeux de données...</p>,
// isDefault: true
},
{
label: "Services",
content: <p>...liste de services...</p>,
},
{
label: "Services",
content: <p>...liste de services...</p>,
},
]}
/>
)
}Also, the arrow keys interactions used to work already, so I don't really understand the need for this PR. Can you please explain? Thank you
mentioning the author of the PR: @BrianRid