Skip to content

Commit

Permalink
fix(useFocusWithin): ignore blur event when window loses focus (#1836)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaticenslaved authored Sep 10, 2024
1 parent 91d5180 commit 216e700
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/hooks/useFocusWithin/useFocusWithin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ function useFocusEvents({
const onBlurHandler = React.useCallback(
(event: React.FocusEvent) => {
if (
event.relatedTarget === null ||
event.relatedTarget === document.body ||
event.relatedTarget === (document as EventTarget)
document.activeElement !== event.target &&
(event.relatedTarget === null ||
event.relatedTarget === document.body ||
event.relatedTarget === (document as EventTarget))
) {
onBlur(event);
targetRef.current = null;
Expand Down

0 comments on commit 216e700

Please sign in to comment.