Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 8fab4b7

Browse files
danielkaxisTigge
authored andcommitted
fix(slider): limit slider value
Limits the slider value to min and max values
1 parent c912bfa commit 8fab4b7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/core/src/Slider/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ export const Slider: React.FC<SliderProps> = ({
340340
}
341341
}, [tickConfig])
342342

343-
const fraction = (value - min) / (max - min)
343+
const fraction = useMemo(
344+
() => clamp((value - min) / (max - min)),
345+
[max, min, value]
346+
)
344347

345348
// Generate the ticks with its position along the x-axis
346349
const tickMarkers = useMemo(

0 commit comments

Comments
 (0)