Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Override "tabIndex" props on Tabs.Tab buttons #7055

Closed
1 of 2 tasks
dev-banana opened this issue Oct 31, 2024 · 0 comments · Fixed by #7081
Closed
1 of 2 tasks

Cannot Override "tabIndex" props on Tabs.Tab buttons #7055

dev-banana opened this issue Oct 31, 2024 · 0 comments · Fixed by #7081

Comments

@dev-banana
Copy link

dev-banana commented Oct 31, 2024

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

7.13.4

What package has an issue?

@mantine/core

What framework do you use?

Vite

In which browsers you can reproduce the issue?

Chrome

Describe the bug

I'm facing an issue when trying to disable focus on the Tabs.Tab buttons by manually setting the tabIndex property to "-1"
The active tab is still rendered with tabindex="0" and others with tabindex="-1".

Here is a minimal code example to reproduce the issue:

<Tabs defaultValue="gallery">
  <Tabs.List>
    <Tabs.Tab value="gallery" tabIndex={-1}>Gallery</Tabs.Tab>
    <Tabs.Tab value="messages" tabIndex={-1}>Messages</Tabs.Tab>
  </Tabs.List>

  <Tabs.Panel value="gallery">Gallery tab content</Tabs.Panel>
  <Tabs.Panel value="messages">Messages tab content</Tabs.Panel>
</Tabs>

If possible, include a link to a codesandbox with a minimal reproduction

No response

Possible fix

export const TabsTab = factory<TabsTabFactory>((_props, ref) => {
  const props = useProps('TabsTab', defaultProps, _props);
  const {
    //...
      
    tabIndex, // <-- get "tabIndex" given by props
      
    ...others
  } = props;

  // ...
    
  return (
    <UnstyledButton
      {...others}
      // ...
      
      // If defined, use the given "tabIndex" props
      tabIndex={tabIndex !== undefined ? tabIndex : (active || ctx.value === null ? 0 : -1)}
      // ...
    >
       // ... 
    </UnstyledButton>
  );
});

Self-service

  • I would be willing to implement a fix for this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant