apache / apache/cordova-electron

alert() and confirm() breaks focus, refocusing BrowserWindow can fix this issue

Open
#280 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
135
Forks
60
Avg merge
1d 6h
Merged PRs (30d)
5

Description

Electron has a known bug: if you call `alert()` or `confirm()`, focus breaks, so for example you can't enter text in an input field after these functions are called. See https://github.com/electron/electron/issues/31917 and https://github.com/electron/electron/issues/41603

Losing and regaining the focus fixes this quirk, so we made a plugin that overrides `alert()` and `confirm()` in order to call `BrowserWindow.getFocusedWindow().blur()` and `focus()` on the main process after the native dialogs functions returns.

(I'm not sure if BrowserWindow.getFocusedWindow() is the best way to get the window, but it works and I think this is a good way to handle it if there are multiple windows)

So if this issue affects your Cordova Electron app, you can use our plugin: https://github.com/cimatti/cordova-electron-dialogs-fix

However I think this fix could be included in future versions of cordova-electron

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the related Electron issues #31917 and #41603 and the alert()/confirm() behavior described here. Compare the cordova-electron-dialogs-fix plugin's BrowserWindow focus handling with the existing cordova-electron integration; done means native dialogs no longer leave input focus broken.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.