Skip to content

fix(slider): onValueCommit not called when range narrows to single value#3832

Open
buyuan-dev wants to merge 1 commit intoradix-ui:mainfrom
buyuan-dev:fix/issue-3829
Open

fix(slider): onValueCommit not called when range narrows to single value#3832
buyuan-dev wants to merge 1 commit intoradix-ui:mainfrom
buyuan-dev:fix/issue-3829

Conversation

@buyuan-dev
Copy link
Copy Markdown

Summary

Fixes a bug where onValueCommit was not fired when dragging a range slider thumb to overlap another.

Problem

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

Root Cause

handleSlideEnd compared individual thumb values using �alueIndexToChangeRef.current as the index. However, when two thumbs land on the same value, indexOf returns � for both, causing the comparison to check the left thumb against itself.

Fix

Changed handleSlideEnd to compare the full value arrays using String(values) !== String(prevValues), matching the approach already used in updateValues.

Testing

  • Manual testing with range slider
  • Verified onValueCommit fires when thumbs overlap
  • All existing slider tests pass

Fixes #3698
Fixes #3829

Fixes radix-ui#3698

When dragging a range slider thumb to overlap another (e.g. [105, 107] → [105, 105]),
onValueCommit was never fired because handleSlideEnd compared individual thumb values
using valueIndexToChangeRef.current, but indexOf returns 0 for both thumbs when they
overlap.

The fix compares the full value arrays using String(values) !== String(prevValues),
matching the approach already used in updateValues.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 18, 2026

⚠️ No Changeset found

Latest commit: d0d73cb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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