Skip to content

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

@fabiofabbri84

Description

@fabiofabbri84

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 electron/electron#31917 and electron/electron#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions