From edca32ca465096366f179a5b1c2ea86c509a1ca7 Mon Sep 17 00:00:00 2001 From: Sterling Camden Date: Wed, 18 Dec 2024 10:01:45 -1000 Subject: [PATCH] Update use-debounced-callback.ts --- .../src/use-debounced-callback/use-debounced-callback.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@mantine/hooks/src/use-debounced-callback/use-debounced-callback.ts b/packages/@mantine/hooks/src/use-debounced-callback/use-debounced-callback.ts index 38589a3416..443f439b3a 100644 --- a/packages/@mantine/hooks/src/use-debounced-callback/use-debounced-callback.ts +++ b/packages/@mantine/hooks/src/use-debounced-callback/use-debounced-callback.ts @@ -15,7 +15,12 @@ export function useDebounceCallback any>( } = useCallback( (...args: Parameters) => { window.clearTimeout(debounceTimerRef.current); - const flush = () => handleCallback(...args); + const flush = () => { + if(debounceTimerRef.current !== 0) { + debounceTimerRef.current = 0 + handleCallback(...args); + } + } lastCallback.flush = flush; debounceTimerRef.current = window.setTimeout(flush, delay); },