As .focus() is being used programmatically in the Slider, the browser cannot make the difference between keyboard and/or mouse navigation (:focus vs :focus-visible).
There is actually a focus event option (focusVisible) that could help, but it is only available on some browsers for now: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#parameters. Firefox already includes it, and Chromium implementation is in progress (from what I read). This might be a way to improve a11y styles for Firefox users, waiting for Chromium ones to get same update?
Also, maybe there would be a way to handle touch devices behaviour differently, to avoid this problem by not using programmatic .focus()?
Bug report
Current Behavior
As
.focus()
is being used programmatically in the Slider, the browser cannot make the difference between keyboard and/or mouse navigation (:focus
vs:focus-visible
).FYI: https://github.com/radix-ui/primitives/blob/83a8c13bf66f3d9f17d77caeb187a69eb146930b/packages/react/slider/src/Slider.tsx#L100 and https://github.com/radix-ui/primitives/blob/83a8c13bf66f3d9f17d77caeb187a69eb146930b/packages/react/slider/src/Slider.tsx#L388
Expected behavior
We should be able to use
:focus-visible
and:focus
states.Reproducible example
https://stackblitz.com/edit/stackblitz-starters-7sbyyl?file=components%2FSlider%2Findex.tsx
Suggested solution
There is actually a focus event option (
focusVisible
) that could help, but it is only available on some browsers for now: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#parameters. Firefox already includes it, and Chromium implementation is in progress (from what I read). This might be a way to improve a11y styles for Firefox users, waiting for Chromium ones to get same update? Also, maybe there would be a way to handle touch devices behaviour differently, to avoid this problem by not using programmatic.focus()
?Thx in advance for your help!!! :pray:
Your environment