From 81a9d8257ca64a51f707860f286c74fe104cbc76 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Tue, 16 Sep 2025 16:15:07 +0200 Subject: [PATCH] Trigger filter change only on slide commit to avoid API overload --- web/components/widgets/slider.tsx | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/web/components/widgets/slider.tsx b/web/components/widgets/slider.tsx index aebef90a..8a8d3fef 100644 --- a/web/components/widgets/slider.tsx +++ b/web/components/widgets/slider.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx' import * as RxSlider from '@radix-ui/react-slider' -import { ReactNode } from 'react' +import {ReactNode, useState} from 'react' const colors = { green: ['bg-teal-400', 'focus:outline-teal-600/30 bg-teal-600'], @@ -58,10 +58,10 @@ export function Slider(props: { >
- {marks?.map(({ value, label }) => ( + {marks?.map(({value, label}) => (
- + ) } @@ -109,6 +109,7 @@ export function RangeSlider(props: { } = props const [trackClasses, thumbClasses] = colors[color] + const [dragValues, setDragValues] = useState<[number, number]>([lowValue, highValue]) return ( setValues(low, high)} + onValueChange={(vals: number[]) => setDragValues([vals[0], vals[1]])} // update continuously for UI feedback + onValueCommit={([low, high]) => setValues(low, high)} // update only on release min={min} max={max} disabled={disabled} >
- {marks?.map(({ value, label }) => ( + {marks?.map(({value, label}) => (
- - {label} - + + {label} +
))}
- - + +
) } const Track = (props: { className: string; children?: ReactNode }) => { - const { className, children } = props + const {className, children} = props return ( {children}