Repository navigation
Add feature to allow editing a slider's value outside of its current range - #353
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #353 +/- ##
==========================================
+ Coverage 84.84% 84.92% +0.08%
==========================================
Files 49 49
Lines 3925 3940 +15
==========================================
+ Hits 3330 3346 +16
+ Misses 595 594 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
@Czaki @brisvag @psobolewskiPhD would you have input on this ? |
brisvag
reviewed
Sep 10, 2026
brisvag
left a comment
Contributor
There was a problem hiding this comment.
Makes sense to me, and I like that this is settable and false by default 👍
tlambert03
requested changes
Oct 7, 2026
tlambert03
left a comment
Member
There was a problem hiding this comment.
thanks for the PR @jules-vanaret ... still some issues to iron out before we can include this though
tlambert03
approved these changes
Oct 16, 2026
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.
PR description
This is a small UX tweak for labeled range sliders.
The problem addressed is that if you edit a slider value label (the text box just above the slider knob) and type a value outside the current slider range, that value gets clamped at the slider bounds. This could be cumbersome for things like contrast-limit controls, where users might expect to be able to type a new endpoint directly instead of first adjusting the min/max edge labels (see napari/napari#9310 ).
Changes
SliderLabel.setValue()normally clamps values to the slider bounds when it refreshes labels. It now accepts aclamp_valuesparameter, which defaults toTrueto retain its existing bounds-clamping behavior for normal label updates.SliderLabel._editing_finished()passesclamp_values=Falsebefore emittingvalueEdited, allowing the owning range slider to receive the raw out-of-range value and decide whether to expand its bounds.I added an opt-in flag to the range slider itself to trigger the new behaviour:
expandRangeOnHandleEdit()setExpandRangeOnHandleEdit(bool)How to use it in practice
With that enabled, typing 110 into the upper handle label will expand the max to 110 and set the handle there instead of being stuck at the old bound.
Reproducer
The small example below illustrates simple- and double-sliders with and without the new range-expansion feature triggered. Try to modify e.g the value of one of the slider above 100 and observe the behavior.