electron: [Bug]: window.focus doesn't work

Preflight Checklist

Electron Version

14.0.0-nightly.20210503

What operating system are you using?

Windows

Operating System Version

Windows 10

What arch are you using?

x64

Last Known Working Electron version

14.0.0-nightly.20210413

Steps to reproduce

Open devtools and execute this code:

win = window.open(location.href)
win.focus()

Expected Behavior

Call to window.focus focuses the window.

Actual Behavior

Call to window.focus doesn’t focus the window.

Testcase Gist URL

No response

Additional Information

It regressed between versions 14.0.0-nightly.20210413 and 14.0.0-nightly.20210426. I suspect this change to cause the problem: https://github.com/electron/electron/pull/28552. Possible fix for the problem is to make a call to:

web_contents()->Focus();

in WebContents::ActivateContents, file shell/browser/api/electron_api_web_contents.cc.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 24 (4 by maintainers)

Most upvoted comments