From a9a6786c95328024666a4ec3778ff55c4007ccda Mon Sep 17 00:00:00 2001 From: mtvare6 Date: Thu, 29 May 2025 02:17:26 +0530 Subject: [PATCH 1/2] Fix #[range] to act as a soft min/max This is a follow up to #2464 --- frontend/src/components/widgets/inputs/NumberInput.svelte | 6 ------ 1 file changed, 6 deletions(-) diff --git a/frontend/src/components/widgets/inputs/NumberInput.svelte b/frontend/src/components/widgets/inputs/NumberInput.svelte index 82a48a497d..4e742d56ae 100644 --- a/frontend/src/components/widgets/inputs/NumberInput.svelte +++ b/frontend/src/components/widgets/inputs/NumberInput.svelte @@ -127,9 +127,6 @@ // The simple `clamp()` function can't be used here since `undefined` values need to be boundless let sanitized = value; - if (typeof min === "number") sanitized = Math.max(sanitized, min); - if (typeof max === "number") sanitized = Math.min(sanitized, max); - text = displayText(sanitized, unit); } @@ -141,9 +138,6 @@ let newValueValidated = newValue !== undefined ? newValue : oldValue; if (newValueValidated !== undefined) { - if (typeof min === "number" && !Number.isNaN(min)) newValueValidated = Math.max(newValueValidated, min); - if (typeof max === "number" && !Number.isNaN(max)) newValueValidated = Math.min(newValueValidated, max); - if (isInteger) newValueValidated = Math.round(newValueValidated); rangeSliderValue = newValueValidated; From 6ec8b4441d0b2128d35f08663b36534731ab8535 Mon Sep 17 00:00:00 2001 From: mtvare6 Date: Tue, 1 Jul 2025 07:52:57 +0530 Subject: [PATCH 2/2] fix increment ranges not drawing back immediately --- .../src/components/widgets/inputs/NumberInput.svelte | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/src/components/widgets/inputs/NumberInput.svelte b/frontend/src/components/widgets/inputs/NumberInput.svelte index 4e742d56ae..955a749ad0 100644 --- a/frontend/src/components/widgets/inputs/NumberInput.svelte +++ b/frontend/src/components/widgets/inputs/NumberInput.svelte @@ -127,6 +127,10 @@ // The simple `clamp()` function can't be used here since `undefined` values need to be boundless let sanitized = value; + if (mode == "Increment") { + if (typeof min === "number") sanitized = Math.max(sanitized, min); + if (typeof max === "number") sanitized = Math.min(sanitized, max); + } text = displayText(sanitized, unit); } @@ -138,6 +142,11 @@ let newValueValidated = newValue !== undefined ? newValue : oldValue; if (newValueValidated !== undefined) { + if (mode == "Increment") { + if (typeof min === "number" && !Number.isNaN(min)) newValueValidated = Math.max(newValueValidated, min); + if (typeof max === "number" && !Number.isNaN(max)) newValueValidated = Math.min(newValueValidated, max); + } + if (isInteger) newValueValidated = Math.round(newValueValidated); rangeSliderValue = newValueValidated;