Skip to content

Commit

Permalink
fix timeout race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
zerts committed Jul 22, 2024
1 parent 1f55be1 commit f8da60b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/ui/ui-kit/Button/HoldableButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const ButtonElement = <As extends ElementType = 'button'>(
const handleMouseDown = useCallback(() => {
setInnerState('hold');
holdDurationCounter.current = Date.now();
clearTimeout(holdTimerRef.current);
holdTimerRef.current = setTimeout(() => {
realButtonRef.current?.click();
}, holdDuration + HOLD_DURATION_MARGIN);
Expand Down

0 comments on commit f8da60b

Please sign in to comment.