From d809e28264bc74a788165dda22067d1392fbf86b Mon Sep 17 00:00:00 2001 From: lunaticenslaved Date: Thu, 5 Sep 2024 21:52:06 +0300 Subject: [PATCH] fix: not fire blur event on firefox window unfocus --- src/hooks/useFocusWithin/useFocusWithin.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hooks/useFocusWithin/useFocusWithin.ts b/src/hooks/useFocusWithin/useFocusWithin.ts index 46e2185d02..c92f69cf35 100644 --- a/src/hooks/useFocusWithin/useFocusWithin.ts +++ b/src/hooks/useFocusWithin/useFocusWithin.ts @@ -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) {