Skip to content

[Bug]: Input elements with autofocus are not focused, nor editable, after an alert() or confirm() #40212

@bradisbell

Description

@bradisbell

Preflight Checklist

Electron Version

26.2.1

What operating system are you using?

Windows

Operating System Version

Windows 11 Pro 22H2 22621.2428

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

Suppose I have a dialog element with an autofocus input:

<dialog>
  <label>
    This should be auto-focused and editable:
    <input autofocus />
  </label>
</dialog>

Now suppose I want to show that dialog:

document.querySelector('dialog').showModal();

The input element is auto-focused as expected and all is well.

Actual Behavior

However, now suppose I want to show that dialog after showing a standard alert() or confirm():

alert('This alert will block the focusable element.');
document.querySelector('dialog').showModal();

The input element is no longer focused, is no longer editable, and seemingly completely stuck until I give focus to a different window entirely, and then come back to the Electron app.

Testcase Gist URL

https://sfo2.digitaloceanspaces.com/festive-sky/alert-focus-test.html

Additional Information

This type of thing works fine in Google Chrome. It seems to be an issue specific to Electron.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy