Skip to content

Commit 6ec8b44

Browse files
committed
fix increment ranges not drawing back immediately
1 parent a9a6786 commit 6ec8b44

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

frontend/src/components/widgets/inputs/NumberInput.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@
127127
128128
// The simple `clamp()` function can't be used here since `undefined` values need to be boundless
129129
let sanitized = value;
130+
if (mode == "Increment") {
131+
if (typeof min === "number") sanitized = Math.max(sanitized, min);
132+
if (typeof max === "number") sanitized = Math.min(sanitized, max);
133+
}
130134
text = displayText(sanitized, unit);
131135
}
132136
@@ -138,6 +142,11 @@
138142
let newValueValidated = newValue !== undefined ? newValue : oldValue;
139143
140144
if (newValueValidated !== undefined) {
145+
if (mode == "Increment") {
146+
if (typeof min === "number" && !Number.isNaN(min)) newValueValidated = Math.max(newValueValidated, min);
147+
if (typeof max === "number" && !Number.isNaN(max)) newValueValidated = Math.min(newValueValidated, max);
148+
}
149+
141150
if (isInteger) newValueValidated = Math.round(newValueValidated);
142151
143152
rangeSliderValue = newValueValidated;

0 commit comments

Comments
 (0)