Skip to content
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

Merged
merged 1 commit into from
Sep 10, 2024

Conversation

lunaticenslaved
Copy link
Contributor

@lunaticenslaved lunaticenslaved commented Sep 5, 2024

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.

@gravity-ui-bot
Copy link
Contributor

Preview is ready.

@gravity-ui-bot
Copy link
Contributor

Visual Tests Report is ready.

@lunaticenslaved lunaticenslaved force-pushed the lunaticenslaved/fix-blur-on-firefox-window-unfocus branch 2 times, most recently from 5fdc882 to d809e28 Compare September 5, 2024 18:52
Comment on lines 99 to 109
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;
}

Copy link
Contributor

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

if (
event.relatedTarget === null ||
event.relatedTarget === document.body ||
event.relatedTarget === (document as EventTarget)
) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ValeraS ValeraS changed the title fix: not fire blur event on firefox window unfocus fix(useFocusWithin): ignore blur event when window loses focus Sep 5, 2024
Copy link
Contributor

@korvin89 korvin89 left a 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 :)

@lunaticenslaved lunaticenslaved force-pushed the lunaticenslaved/fix-blur-on-firefox-window-unfocus branch from d809e28 to f723c13 Compare September 8, 2024 09:46
@lunaticenslaved
Copy link
Contributor Author

Add comment, please. It looks a little bit weird without context :)

Removed the block of code. It looks more obvious now I hope.

@ValeraS ValeraS merged commit 216e700 into main Sep 10, 2024
6 checks passed
@ValeraS ValeraS deleted the lunaticenslaved/fix-blur-on-firefox-window-unfocus branch September 10, 2024 10:01
@ValeraS ValeraS linked an issue Sep 14, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switching language on Firefox Ubuntu close select
4 participants