Skip to content

Commit

Permalink
Add leading to set action name debounce
Browse files Browse the repository at this point in the history
So that the delay does not apply when updating the name from length 0 to something
  • Loading branch information
microbit-grace committed Dec 3, 2024
1 parent 7ab49ff commit 532d33f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/ActionNameCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ const ActionNameCard = ({

const debouncedSetActionName = useMemo(
() =>
debounce((id: ActionData["ID"], name: string) => {
setActionName(id, name);
}, 400),
[setActionName]
debounce(
(id: ActionData["ID"], name: string) => {
setActionName(id, name);
},
400,
{ leading: localName.length === 0 }
),
[localName.length, setActionName]
);

const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
Expand Down

0 comments on commit 532d33f

Please sign in to comment.