Skip to content

Commit

Permalink
fix(useClickOutside): reset waitingForTrigger if clicking outside target
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Nov 15, 2024
1 parent 69413ac commit 3000ee3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/useClickOutside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ function useClickOutside(

if (currentTarget && contains(currentTarget, e.target as any)) {
waitingForTrigger.current = true;
} else {
// When clicking on scrollbars within current target, click events are not triggered, so this ref
// is never reset inside `handleMouseCapture`. This would cause a bug where it requires 2 clicks
// to close the overlay.
waitingForTrigger.current = false;
}
});

Expand Down

0 comments on commit 3000ee3

Please sign in to comment.