react-spectrum
react-spectrum copied to clipboard
[Slider] Custom validation for multiple thumb values
Provide a general summary of the feature here
<Slider> does not allow thumbs to cross each other. This makes it impossible to implement our own validation logic when collisions occur. I would like a way to implement custom validation logic for multi-thumb values.
๐ค Expected Behavior?
I expect that my onChange handler will be responsible for validating values, and will not be limited by built-in logic beyond the constraints specified by minValue / maxValue / step
๐ฏ Current Behavior
Sliders enforce that thumb values cannot exceed neighboring values. This ensures that values are ordered, but prohibits custom UX for collisions.
https://github.com/adobe/react-spectrum/blob/cf0846eb49fcdde669e9dc4c0c2d2109b50e46dd/packages/%40react-stately/slider/src/useSliderState.ts#L216-L221
๐ Possible Solution
Perhaps an additional prop like disableCollision could disable the constraint on neighboring values
๐ฆ Context
I have two slider thumbs "left" and "right" that define a range, when I drag the left thumb beyond the right thumb I want the left thumb to pull the right thumb along with it. This makes it easier for a user to move the left thumb to a desired value in one movement instead of having to manually shuffle the right value along.
Instead, the "left" thumb halts at the "right" value. If thumbs did not come with prescribed collision logic, I could implement the constraint myself. However, since the right thumb prohibits the left thumb from moving past it, there is no way for me to detect when the user intends to drag further.
๐ป Examples
No response
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response