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

[Bug]: Confirm/Alert popups break focus #41603

Open
3 tasks done
LqdBcnAtWork opened this issue Mar 15, 2024 · 14 comments
Open
3 tasks done

[Bug]: Confirm/Alert popups break focus #41603

LqdBcnAtWork opened this issue Mar 15, 2024 · 14 comments
Labels
29-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/

Comments

@LqdBcnAtWork
Copy link

LqdBcnAtWork commented Mar 15, 2024

Preflight Checklist

Electron Version

29.1.4

What operating system are you using?

Windows

Operating System Version

Edition: Windows 10 Home | Version: 22H2 | OS build: 19045.4170 | Experience: Windows Feature Experience Pack 1000.19054.1000.0

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

Using a popup (alert or confirm) then trying to focus an input element shouldn't cause issues.

Actual Behavior

When the application is launched, there are no problems interacting with an input element.

After clicking on a popup from confirm or alert, trying to focus the window that just caused the popup (namely an input element) will no longer work.

Focusing on another window and refocusing the window repairs the issue.

Testcase Gist URL

https://gist.github.com/LqdBcnAtWork/9af23d4faa33e74874cd08ffbc8e4ed6

Additional Information

I've noticed this issue for a while, but didn't catch onto the issue being caused by popups. I thought it was random and was caused by some strange interaction with focus that I was causing on my end. Having diagnosed the problem's cause, creating a Fiddle that could replicate it took seconds.

I mention this because it means the issue has existed for many major versions of Electron. How far back is unknown to me. But it goes at least as far back as version 21. I tried version 12.2.3 for fun with Fiddle and the problem persists.

I believe this is caused by the popup taking focus, but the window doesn't recognise that it gets focus back when the popup is closed. I also think this issue might be on Chromium's end. But I'm unsure since neither Chrome or Edge (the only other Chromium apps I have available to me) use the same kind of popup for alert and confirm or display this issue.

@Maniiisha-sachdeva
Copy link

here is the main code..
function showAlert() {
alert("This is a test alert.");
window.focus();
}
function showPopupAndFocusInput() {
alert("This is a test alert.");
document.getElementById("myInput").focus();
window.focus();
}

@Prinzhorn
Copy link
Contributor

I can confirm this on Ubuntu, however, I cannot confirm the claim that this has always been this way. The Fiddle works perfectly fine for me with v28.2.7 and breaks starting with v29.0.0-alpha.1. v27.3.6 and v26.6.10 also work for me.

@LqdBcnAtWork
Copy link
Author

I can confirm this on Ubuntu, however, I cannot confirm the claim that this has always been this way. The Fiddle works perfectly fine for me with v28.2.7 and breaks starting with v29.0.0-alpha.1. v27.3.6 and v26.6.10 also work for me.

I would not be surprised if Windows changed something that broke it for Electron.

@Maniiisha-sachdeva are you implying that calling window.focus(); after a popup will repair this focus issue?

I'll have to try this on Monday.

@LqdBcnAtWork
Copy link
Author

LqdBcnAtWork commented Mar 18, 2024

I tried calling window.focus and .focus on an input element, and neither fixed the focus issue.

Also tried these versions:
(just the alert/confirm bug, not the focus function)

version       worked
28.2.7        ❌
27.3.6        ❌
26.6.10       ❌
21.0.0-beta.3 ❌ //the version of 21 that I noticed the issue with previously.
24.1.0        ❌ //version I had bumped the project to from 21.

Seeing that v28, v27 and v26 failed for me but not @Prinzhorn, I believe this is primarily a Windows issue. I can't test other versions of Windows unfortunatly. But I find it quite bizarre that it stops working on Ubuntu with v29.

Either way it's reassuring that it's not just me and my code. I'll have to implement a workaround for now.

edit: changed emoji for clarity.

@m-eraf
Copy link

m-eraf commented Mar 19, 2024

in this when i changed the input type to number then i am able to change the number by its up and down arrow but not able to type in it and as i am switching the tab its started working can i work on it further?

@jkleinsc jkleinsc added has-repro-gist Issue can be reproduced with code at https://gist.github.com/ 29-x-y labels Mar 19, 2024
@github-project-automation github-project-automation bot moved this to 👀 Unsorted Items in 29-x-y Mar 19, 2024
@clavin clavin moved this from 👀 Unsorted Items to 👍 Does Not Block Stable in 29-x-y Mar 20, 2024
@electron-issue-triage
Copy link

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@LqdBcnAtWork
Copy link
Author

Tried the fiddle with 31.0.1 and 32.0.0-alpha.2

Still broken for me.

@pushkin-
Copy link

dupe of this, right? #31917

@LqdBcnAtWork
Copy link
Author

dupe of this, right? #31917

Huh, didn't find that before. It's 3 years old too.

Lovely.

@vaibhavpanday
Copy link

hello guys, please use electron version lower than 29.

use electron 28.3.3 it will solve you problem.

@Prinzhorn
Copy link
Contributor

please use electron version lower than 29.

Nice try 🕵️‍♂️💻, end of life was 11 Jun 2024

@LqdBcnAtWork
Copy link
Author

@vaibhavpanday
hello guys, please use electron version lower than 29.

use electron 28.3.3 it will solve you problem.

What Prinzhorn said about being EOL. Plus that version also doesn't work. Just tested it to see.

Honestly something like what I mentioned here would not only give us an option to solve this issue, but it would add a bunch more as well.

@fabiofabbri84
Copy link

If you are using Electron with Cordova, we have made a Cordova plugin that fix this issue: https://github.com/cimatti/cordova-electron-dialogs-fix

@fabiofabbri84
Copy link

I found also this: #19977

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
29-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/
Projects
No open projects
Status: 👍 Does Not Block Stable
Development

No branches or pull requests

8 participants