From 36b1182565b065efcf231e269ae9ef19307791d6 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 10 Dec 2025 20:32:58 +0200 Subject: [PATCH] feat(widgets/toggle): disable if going too fast --- apps/client/src/widgets/react/FormList.tsx | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/client/src/widgets/react/FormList.tsx b/apps/client/src/widgets/react/FormList.tsx index f1374712c..fac69efde 100644 --- a/apps/client/src/widgets/react/FormList.tsx +++ b/apps/client/src/widgets/react/FormList.tsx @@ -133,18 +133,25 @@ export function FormListItem({ className, icon, value, title, active, disabled, ); } -export function FormListToggleableItem({ title, currentValue, onChange, ...props }: Omit & { +export function FormListToggleableItem({ title, currentValue, onChange, disabled, ...props }: Omit & { title: string; currentValue: boolean; - onChange(newValue: boolean): void; + onChange(newValue: boolean): void | Promise; }) { + const isWaiting = useRef(false); + return ( - { - e.stopPropagation(); - if (!props.disabled) { - onChange(!currentValue); - } - }}> + { + e.stopPropagation(); + if (!disabled && !isWaiting.current) { + isWaiting.current = true; + await onChange(!currentValue); + isWaiting.current = false; + } + }}>