-
-
Notifications
You must be signed in to change notification settings - Fork 88
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] Activate on click instead of mouse/pointerdown #1323
Comments
Tabs are not modal, and don't take an action that changes the application's state, so there is nothing to cancel. Mousedown feels more responsive. |
@colmtuite "Mousedown feels more responsive", 💯 but the current behavior doesn't seem accessible, not all the time. As I read Success Criterion 2.5.2 Pointer Cancellation we don't meet this criteria. Now, it's required to pass level A, and enterprise most of the time needs to meet level AA. So I conclude that at the minimum we need a prop to allow to configure this behavior. I imagine that the root problem is that if the active tab has a state (e.g. an input) and a user mouse down on a tab by mistake, the state of the user gets unmounted and gets lost. Some examples in the wild Screen.Recording.2025-01-11.at.19.30.46.mov
Screen.Recording.2025-01-11.at.19.35.00.movOff-topic. On a different tangent, I see no issue about the story for the disabled state,
component: tabs
|
That's debatable (as is often the case).
ARIA guidelines recommend that left/right activate the next/previous tab immediately (which is why we enable this by default). Emulating that with mousedown qualifies as "essential" imo.
This example you shared doesn't even have any keyboard a11y, so it's just an inaccessible UI, and not a valid reference.
Other tabbed UIs on Ashby activate on mousedown. So again, not a great reference imo. I would guess it's unintentional, and they just haven't yet migrated some parts of their UI to Radix. Screen.Recording.2025-01-11.at.20.34.33.mov |
Ok maybe. We can always sleep on this and wait for a11y feedback from community members. We have this issue people can contribute to, and if new strong arguments are made, we can then resume. How I think the WCAG 2.1 spec should be read: they define "essential" as:
https://www.w3.org/TR/WCAG21/#dfn-essential. So to have "essential" as true, we need both to be true:
From there we can conclude that "essential" is always false. And from there we can conclude that in the vast majority of the time, acting on mousedown break this A level rule. Now, because we save something like 100ms by acting on mousedown, and enterprise that are regulated can't use it, I conclude that this behavior needs a prop to control (depending on your use case).
A tab component isn't a virtual keyboard component, so this note they left seems off-topic, but it's a great example of what an essential use case looks like. We can't build a keyboard virtual component without responding to mousedown.
They have some level of keyboard a11y: Screen.Recording.2025-01-12.at.12.44.59.mov |
Two more data points:
Off-topic This makes me think: maybe there is purpose in transfering all Radix Primitives and MUI Base issues to here. All the ones that are still relevant, this way, we could have people upvote them (so we better prioritize) and we would have a clear backlog (instead of community opening duplicates, issues that mixes 3 different things, etc). |
Originally posted by @oliviertassinari in #1318 (comment)
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.Examples that activate on click, that is right:
Examples that activate on pointerdown by default but can be controlled:
shouldSelectOnPressUp
Examples that activate on pointerdown, that is 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.The text was updated successfully, but these errors were encountered: