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

[Slider] Swap thumbs on range slider when thumbs are overlapping #1220

Open
benjavicente opened this issue Dec 23, 2024 · 1 comment
Open
Labels
component: slider This is the name of the generic UI component, not the React module! regression A bug, but worse

Comments

@benjavicente
Copy link

benjavicente commented Dec 23, 2024

Coming from @mui/base, @base-ui-components/react seems to lack the correct thumb placement (will be fixed with #1175), marks, and the ability to swap thumbs. While swapping values does not follow the Slider WAI-ARIA design pattern (see relevant RadixUI discussion about that), swapping might provide better UX, specially when thumbs are overlapping.

Where is a comparison with@base-ui-components/react vs @mui/base. In the base ui example, since the clicks happen on the left side of the thumb, the left thumb is selected, even thought there is an intent to slide to the right.

Screen.Recording.2024-12-23.at.14.04.18.mov
Screen.Recording.2024-12-23.at.14.06.45.mov

So, it could be great to have the ability to enable always thumb swaping like in mui-base, and would be amazing if this library manages to include a threshold of when it should overlap. I couldn't find a library that does this last behavior 🤔

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 23, 2024
@mj12albert mj12albert added component: slider This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature labels Dec 24, 2024
@oliviertassinari oliviertassinari added regression A bug, but worse and removed enhancement This is not a bug, nor a new feature labels Dec 24, 2024
@oliviertassinari oliviertassinari changed the title Swap thumbs on range slider when thumbs are overlapping [slider] Swap thumbs on range slider when thumbs are overlapping Dec 24, 2024
@aarongarciah aarongarciah changed the title [slider] Swap thumbs on range slider when thumbs are overlapping [Slider] Swap thumbs on range slider when thumbs are overlapping Dec 25, 2024
@aarongarciah aarongarciah removed their assignment Dec 27, 2024
@mj12albert
Copy link
Member

mj12albert commented Jan 1, 2025

Related to #420

@benjavicente We decided to not allow thumbs to cross each other for two main reasons:

  1. In the legacy package, the thumbs never actually swap positions. When they appear to "swap", focus just magically moves to the other thumb which is not great for accessibility.
  2. Solving the above means actually reordering the thumb components/elements in the DOM as they are dragged around, and will require a more complicated API - e.g. using a function child to render thumbs, instead of manually composing them one by one - which is also something we want to avoid at the moment

would be amazing if this library manages to include a threshold of when it should overlap. I couldn't find a library that does this last behavior 🤔

There is a minStepsBetweenValues prop that you can use to enforce the min distance between thumbs and prevent overlap (denominated in no. of steps) in a range slider, and will help avoid landing on a "range" like 10-10.
(I think radix has a similar prop)

<Slider.Root value={[10, 20]} step={1} minStepsBetweenValues={1} />

@mj12albert mj12albert removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! regression A bug, but worse
Projects
None yet
Development

No branches or pull requests

4 participants