Skip to content

Commit

Permalink
fix: not fire blur event on firefox window unfocus
Browse files Browse the repository at this point in the history
  • Loading branch information
lunaticenslaved committed Sep 5, 2024
1 parent 4c3d070 commit d809e28
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/hooks/useFocusWithin/useFocusWithin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ export function useFocusWithin(props: UseFocusWithinProps) {
return;
}

if (
document.activeElement === event.target &&
(event.target instanceof HTMLButtonElement ||
event.target instanceof HTMLInputElement ||
event.target instanceof HTMLTextAreaElement ||
event.target instanceof HTMLSelectElement) &&
!event.target.disabled
) {
return;
}

isFocusWithinRef.current = false;

if (onBlurWithin) {
Expand Down

0 comments on commit d809e28

Please sign in to comment.