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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Jan 10, 2025

Fixes #1317

@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 from 048b73d to e59ac6f Compare January 10, 2025 15:22
@mj12albert mj12albert force-pushed the fix/tab-mouse-button branch 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?

onTabActivation(tabValue, event.nativeEvent);
},
onFocus(event) {
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.

I'm confused. Why does the tab activate on mouse down? I thought this point of using onClick is cancellability. Having to use activateOnFocus to get this behavior feels wrong, this is a different concern.

I would see those as correct:

those as wrong:

Screen.Recording.2025-01-10.at.23.56.37.mov

But then maybe it's OK if we assume this: applications that have a significant UI state behind tabs must use <a> to trigger the actions. a link triggering on onClick, means it's OK. And then if they don't use a <a>, it means that the state is not that important, so maybe mouseDown is better. I don't really buy that narrative though to be honest, e.g. navigating inside Ashby's UI.

Copy link

Choose a reason for hiding this comment

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

John Carmack had a good argument for acting on press wherever possible in that the UI feels insanely faster and more responsive. I've switched most things to act on press (mouse/key down) and it is 10000% true. Some tabbed form component for example had some quite slow tabs since it was quite complex and this hid its slowness.

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-primary mouse button
3 participants