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

[useButton][base] Fix tabIndex not being forwarded #38417

Merged
merged 4 commits into from
Aug 11, 2023

Conversation

DiegoAndai
Copy link
Member

Closes #38368

The tabIndex value was only taken into consideration for certain cases, so its value would be lost when not taken into consideration: https://codesandbox.io/s/usebutton-tabindex-lost-sd37h8?file=/Demo.tsx

This fix adds the tabIndex value to the getRootProps return value initialization. This way, if explicitly provided, then it will be included in getRootProps return value. The previous behavior is maintained as the tabIndex is only added as a starting point.

@DiegoAndai DiegoAndai added bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Aug 10, 2023
@mui-bot
Copy link

mui-bot commented Aug 10, 2023

Netlify deploy preview

https://deploy-preview-38417--material-ui.netlify.app/

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 780c619

@DiegoAndai
Copy link
Member Author

Codesandbox with fix: https://codesandbox.io/s/usebutton-tabindex-lost-pm839d

Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 just a small suggestion to make the test name more informative.

packages/mui-base/src/useButton/useButton.test.tsx Outdated Show resolved Hide resolved
Co-authored-by: Michał Dudak <michal.dudak@gmail.com>
Signed-off-by: Diego Andai <diego@mui.com>
@DiegoAndai DiegoAndai merged commit 38b7936 into mui:master Aug 11, 2023
18 checks passed
@DiegoAndai DiegoAndai deleted the use-button-tab-index-fix branch August 11, 2023 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: button This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC][useButton][base] tabIndex should be returned by getRootProps if explicitly provided
3 participants