-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(useFocusWithin): ignore blur event when window loses focus #1836
fix(useFocusWithin): ignore blur event when window loses focus #1836
Conversation
Preview is ready. |
Visual Tests Report is ready. |
5fdc882
to
d809e28
Compare
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; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this and add document.activeElement !== event.target && (...)
to that check
uikit/src/hooks/useFocusWithin/useFocusWithin.ts
Lines 187 to 191 in 4c3d070
if ( | |
event.relatedTarget === null || | |
event.relatedTarget === document.body || | |
event.relatedTarget === (document as EventTarget) | |
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment, please. It looks a little bit weird without context :)
d809e28
to
f723c13
Compare
Removed the block of code. It looks more obvious now I hope. |
Issue #1737
Apparently when Firefox's window loses focus a blur event is fired.
It can be reproduced on Linux GNOME with
super
+space
to switch language. I do not know whether or not it works on KDE.It can be emulated on Mac with
control
+space
to open search bar.On Windows with switching language by
win
+space
it works fine.Maybe this solution can help.