[Slider] onValueCommit not called when start/end are equal #3329
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
onValueCommit not called when start/end are equal
Description
For multi-value sliders where two values are allowed to overlap,
onValueCommit
will not be called for overlapping values.#1760
Steps to reproduce
Dragging the END value equal to the START value will trigger
onValueChange
but will not triggeronValueCommit
, despite the end value having changed.Screen.Recording.2025-01-18.at.3.07.16.PM.mov
Cause
updateValues()
is responsible for settingvalueIndexToChangeRef
, which is used later byhandleSlideEnd()
to determine if changes have been made. The problem is thatupdateValues()
will attempt to find the relevant index by searching for the current value -- using the first index found. If the array contains multiple identical values, this strategy will fail.Effectively when multiple Thumbs have identical values, the first index is always used. This means that
handleSlideEnd()
will only check for changes in the first Thumb's value.Changing values using the keyboard works as expected, this bug only affects dragging behavior. Changing the first value always works as expected.
Fix
updateValues()
already receives an index parameter; it's used to validate that the minSteps has been satisfied, and in some cases used for change detection. Using this index instead of trying to infer it by searching the first occurrence of the value solves the issue.