From f723c13dbd56d6872782f3754266f6b2fb459028 Mon Sep 17 00:00:00 2001 From: lunaticenslaved Date: Sun, 8 Sep 2024 12:45:49 +0300 Subject: [PATCH] fix: not fire blur event on firefox window unfocus --- src/hooks/useFocusWithin/useFocusWithin.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hooks/useFocusWithin/useFocusWithin.ts b/src/hooks/useFocusWithin/useFocusWithin.ts index 46e2185d02..3a66c97749 100644 --- a/src/hooks/useFocusWithin/useFocusWithin.ts +++ b/src/hooks/useFocusWithin/useFocusWithin.ts @@ -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;