Skip to content

fix(slider): onValueCommit not called when range is narrowed to single value #3829

Open
zaewc wants to merge 2 commits intoradix-ui:mainfrom
zaewc:fix/slider-range-narrow-commit
Open

fix(slider): onValueCommit not called when range is narrowed to single value #3829
zaewc wants to merge 2 commits intoradix-ui:mainfrom
zaewc:fix/slider-range-narrow-commit

Conversation

@zaewc
Copy link
Copy Markdown

@zaewc zaewc commented Mar 13, 2026

Description

Fixes #3698

When dragging the right thumb of a range slider to overlap the left thumb (e.g. [105, 107][105, 105]),
onValueCommit was never fired.

handleSlideEnd compared individual thumb values using valueIndexToChangeRef.current as the index.
However, this index is remapped to the sorted position inside updateValues when two thumbs land on the
same value, indexOf returns 0 for both. So handleSlideEnd ended up comparing the left thumb's value
against itself and concluded nothing had changed.

The fix compares the full value arrays using String(values) !== String(prevValues), which is the same
approach already used inside updateValues.

zaewc added 2 commits March 13, 2026 10:37
Covers the regression where narrowing a range to a single value from the
right thumb fails to fire onValueCommit due to index remapping after sort.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: 610e5b8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@radix-ui/react-slider Patch
radix-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slider range does not allow narrowing the range to one value

1 participant