diff --git a/apps/web/lib/features/task/task-labels.tsx b/apps/web/lib/features/task/task-labels.tsx index 04b266a16..e8bdd7b44 100644 --- a/apps/web/lib/features/task/task-labels.tsx +++ b/apps/web/lib/features/task/task-labels.tsx @@ -5,7 +5,7 @@ import { PlusIcon } from 'lib/components/svgs'; import { TaskLabelForm } from 'lib/settings'; import { TaskLabelsDropdown, taskUpdateQueue } from './task-status'; import { debounce, isEqual } from 'lodash'; -import { useCallback, useRef } from 'react'; +import { useCallback, useMemo, useRef } from 'react'; type Props = { task: Nullable; @@ -28,7 +28,7 @@ export function TaskLabels({ const latestLabels = useRef([]); const onValuesChange = useCallback( - debounce((_: any, values: string[] | undefined) => { + (_: any, values: string[] | undefined) => { if (!$task.current) return; if (!isEqual(latestLabels.current, values)) { @@ -49,10 +49,15 @@ export function TaskLabels({ taskLabels, values ); - }, 2000), + }, [$task, taskLabels, updateTask, latestLabels] ); + const onValuesChangeDebounce = useMemo( + () => debounce(onValuesChange, 2000), + [onValuesChange] + ); + const tags = (task?.tags as typeof taskLabels | undefined)?.map( (tag) => tag.name || '' ); @@ -60,7 +65,7 @@ export function TaskLabels({ return ( <>