Skip to content

Commit

Permalink
fix: fixing stuck filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
isqua committed Oct 26, 2023
1 parent 5a0ca23 commit 423f7f7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/features/toc/ui/Menu/Context/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export const useFilterInput = () => {
const timeout = useRef<number>(0)

const onChangeHandler = useCallback((value: string) => {
if (timeout.current) {
clearTimeout(timeout.current)
}

const text = value.trim()

if (text === '') {
Expand All @@ -58,12 +62,8 @@ export const useFilterInput = () => {
onFilterStart()
}

if (timeout.current) {
clearTimeout(timeout.current)
}

timeout.current = window.setTimeout(() => {
onChange(text)
onChange(text.trim())
}, FILTER_DELAY_IN_MS)
}, [isFiltering, onChange, onFilterStart, onReset])

Expand Down

0 comments on commit 423f7f7

Please sign in to comment.