Repository navigation
Conversation
Do not publish a typed min above the max, or a max below the min, while typing. On blur, publish the clamped result as both value and drag_value in every updatemode. Before, updatemode="drag" left value out of order after blur, and updatemode="mouseup" left drag_value stale. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Closes #4222.
The number inputs of
dcc.RangeSlidercould publish avalueordrag_valuewith the low end above the high end. I listed this under "Not covered by this PR" in #3926. The two PRs do not depend on each other and can merge in either order.The bug
For a slider at
[5, 15], type 18 into the min input and press Tab. The slider and both inputs show[15, 15], but the callbacks get:updatemodevaluedrag_value"drag"[18, 15][18, 15]"mouseup"[15, 15][18, 15]The max input does the same in the other direction (
[5, 3]after typing 3).allowCrossmakes no difference.The cause is in the input handlers in
RangeSlider.tsx:onChangepublished any typed number that passed themin,maxandstepcheck, without comparing it to the other handle.onBlurclamped the number to the other handle, but published the result only withupdatemode="mouseup", and only asvalue.Changes
onChangeof both inputs: a typed number past the other handle is not published.onBlurof both inputs: the clamped pair is published asvalueanddrag_valuein both update modes.test_slkb002_range_input_constrained_by_min_max: its last line asserteddrag_value is [7, 5], the out-of-order pair. It now asserts[5, 5].test_slkb006_range_input_keeps_handle_order, run fordragandmouseup. It types past the other handle in each input, then checks the final props and that no callback got an out-of-order pair.With this PR the example above ends with
valueanddrag_valueboth at[15, 15]in both update modes.What does not change
allowCross=TrueandallowCross=False. That was already the behavior on blur. This PR only fixes what is published.dragmode, a typed number that keeps the pair in order is still published on each keystroke. Typing 18 publishes[1, 15]after the first digit.Tests
components/dash-core-components/tests/integration/sliders/: 36 passed in headless Chrome.test_sliders_keyboard_input.py: 7 passed in headless Firefox.RangeSlider.tsx, 3 of those 7 fail:test_slkb002_range_input_constrained_by_min_max:drag_value is [7, 5]test_slkb006_range_input_keeps_handle_order[drag]:value is [18, 15], drag_value is [18, 15]test_slkb006_range_input_keeps_handle_order[mouseup]:value is [15, 15], drag_value is [18, 15]Contributor Checklist
dev(fix or chore) ornext(feature, new API, breaking change), see Which branch to targetvalueanddrag_valueon bluroptionals
CHANGELOG.mdGenerated with Claude Code