adobe / adobe/react-spectrum

[Slider] Custom validation for multiple thumb values

Open
#6,338 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Provide a general summary of the feature here

`` 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.