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

[Tabs] Fix tabs activating incorrectly on non-primary button clicks #1318

Merged
merged 6 commits into from
Jan 16, 2025

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Jan 10, 2025

Fixes #1317

Sorry, something went wrong.

@mj12albert mj12albert added component: tabs This is the name of the generic UI component, not the React module! bug 🐛 Something doesn't work labels Jan 10, 2025
Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 504cda3
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/67813e7c3125ad00088e5007
😎 Deploy Preview https://deploy-preview-1318--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mj12albert mj12albert force-pushed the fix/tab-mouse-button branch 2 times, most recently from e59ac6f to 504cda3 Compare January 10, 2025 15:36
@mj12albert mj12albert marked this pull request as ready for review January 10, 2025 15:40
isPrimaryButtonRef.current = false;
}

if (!event.button || event.button === 0) {
Copy link
Member

@oliviertassinari oliviertassinari Jan 10, 2025

Choose a reason for hiding this comment

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

We use

Suggested change
if (!event.button || event.button === 0) {
if (event.button === 0) {

in all Material UI codebase. I have never seen someone open a bug because event.button is missing. Could this reduce the bundle size here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried removing this check in NumberField here too but without it a test fails: https://app.circleci.com/pipelines/github/mui/base-ui/7042/workflows/cc6f84c4-5cc2-488c-b741-ebb30c275d4a/jobs/61996/parallel-runs/0/steps/0-106

Not sure if it's just a test issue but I'd prefer to keep the main button check the same for now CC @atomiks

@mj12albert mj12albert force-pushed the fix/tab-mouse-button branch from 504cda3 to 6e63c2b Compare January 13, 2025 05:59
</Tabs.Root>,
);

await user.pointer({ keys: '[MouseLeft>]', target: getAllByRole('tab')[1] });
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting syntax?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://testing-library.com/docs/user-event/pointer/#pressing-a-button-or-touching-the-screen
pressing and releasing, also works for keyboard 😬 user.keyboard('{a>}') // press a without releasing it

@mj12albert mj12albert merged commit 8256095 into mui:master Jan 16, 2025
23 checks passed
@mj12albert mj12albert deleted the fix/tab-mouse-button branch January 17, 2025 06:52
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: tabs This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tabs] Tab activates when clicking non-main mouse button
5 participants