From 26e00192d9729be0e6e2e8ebe2875036e5d43c98 Mon Sep 17 00:00:00 2001 From: Anders Rantala Hunderi Date: Fri, 11 Sep 2026 11:44:19 +0200 Subject: [PATCH 1/2] Slider: Made min-max clamp only apply if clamping would change the value --- frontend/src/lib/components/Slider/slider.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/components/Slider/slider.tsx b/frontend/src/lib/components/Slider/slider.tsx index ae240b05c8..3461c8089f 100644 --- a/frontend/src/lib/components/Slider/slider.tsx +++ b/frontend/src/lib/components/Slider/slider.tsx @@ -359,7 +359,11 @@ export const Slider = React.forwardRef { From 2f9254fc9c57b0ad0a2f7dff20b9e2c857a2dc8a Mon Sep 17 00:00:00 2001 From: Anders Rantala Hunderi Date: Tue, 15 Sep 2026 16:47:16 +0200 Subject: [PATCH 2/2] Made sure controlled slider value is prioritized --- frontend/src/lib/components/Slider/slider.tsx | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/frontend/src/lib/components/Slider/slider.tsx b/frontend/src/lib/components/Slider/slider.tsx index 3461c8089f..bc1d8b2c85 100644 --- a/frontend/src/lib/components/Slider/slider.tsx +++ b/frontend/src/lib/components/Slider/slider.tsx @@ -222,7 +222,9 @@ export const Slider = React.forwardRef defaultedProps.min) { + if (eventDetails.activeThumbIndex === 0 && thumbValue > defaultedProps.min) { setMinLocked(false); - } else if (eventDetails.activeThumbIndex === 1 && activeValue < defaultedProps.max) { + } else if (eventDetails.activeThumbIndex === 1 && thumbValue < defaultedProps.max) { setMaxLocked(false); } } else { - if (activeValue > defaultedProps.min) { + if (thumbValue > defaultedProps.min) { setMinLocked(false); } - if (activeValue < defaultedProps.max) { + if (thumbValue < defaultedProps.max) { setMaxLocked(false); } } - if (defaultedProps.snapToMarkers && !allMarkers.includes(activeValue)) { + if (defaultedProps.snapToMarkers && !allMarkers.includes(thumbValue)) { let snapTarget: SnapTarget = "nearest"; // For keyboard movement, we should always go a new marker marker if (eventDetails.reason === "keyboard") { - snapTarget = prevActiveValue - activeValue < 0 ? "next" : "prev"; + snapTarget = prevThumbValue - thumbValue < 0 ? "next" : "prev"; } const snappedValue = getSnappedValue(allMarkers, newValue, snapTarget); // Only apply the snapped value if necessary - if (!isEqual(snappedValue, internalValue)) { + if (!isEqual(snappedValue, activeValue)) { updateValue(snappedValue, eventDetails); } } else { @@ -341,7 +343,7 @@ export const Slider = React.forwardRef(null); - let clampedValue = isDualSlider ? clone(internalValue as number[]) : ([internalValue, internalValue] as number[]); + let clampedValue = isDualSlider ? clone(activeValue as number[]) : ([activeValue, activeValue] as number[]); if (prevMin !== defaultedProps.min || prevMax !== defaultedProps.max) { setPrevMin(defaultedProps.min); @@ -361,7 +363,7 @@ export const Slider = React.forwardRef { - if (!isDualSliderValue(internalValue)) { + if (!isDualSliderValue(activeValue)) { updateValue(v, { reason: "marker-clicked" }, true); inputRefs[0].current?.focus(); } else { const nearestThumbIndex = minBy([0, 1], (idx) => - Math.abs(internalValue[idx] - v), + Math.abs(activeValue[idx] - v), )!; - const newValue = [...internalValue]; + const newValue = [...activeValue]; newValue[nearestThumbIndex] = v; updateValue(newValue, { reason: "marker-clicked" }, true);