electron: Undo/Redo/Cut/Copy/Paste & more Not work using Menubar in Windows
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
- 5.0.3
- Operating System:
- Windows 10 (1809)
- Last Known Working Electron version:
- 4.2.4
Expected Behavior
Selecting Undo/Redo/Cut/Copy/Paste/ZoomIn/ZoomOut/ResetZoom from menu bar with mouse performs those various functions.
Actual Behavior
Selecting these options from the menubar using the mouse seems to have no effect. Using keyboard shortcuts does work ok.
Both mouse & keyboard works ok for all functions in MacOS 10.14.5.
To Reproduce
https://github.com/electron/fiddle/releases/tag/v0.8.1 Download and run, then try Edit and View menus. This uses 5.0.1
I have same problem in my own app using 5.0.3. Problem eliminated by downgrading to 4.2.4.
Additional Information
My app uses standard MenuItem roles:
{ role: 'resetzoom' },
{ role: 'zoomin' },
{ role: 'zoomout' },
Electron Fiddle does the same: https://github.com/electron/fiddle/blob/88ce4a76e97c4c93821306b59b3de9a147378058/src/main/menu.ts
item.submenu.push({ type: 'separator' }, { role: 'resetzoom' }, { role: 'zoomin' }, { role: 'zoomout' }); // Add zooming actions
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 16 (10 by maintainers)
I can confirm that the following roles do not work on Windows with Electron v5.0.8 and v6.0.0:
undoredocutcopypastepasteAndMatchStyleselectAlldeleteresetZoomzoomInzoomOutHere’s a fiddle gist: https://gist.github.com/javan/69c1075d389acd5a3437c6459e4c6a6d
The underlying issue may be the window losing focus (as noted in https://github.com/electron/electron/issues/18518), which appears to happen when you interact with the menu.
Note how the window blurs when clicking the menu 👎
This doesn't happen with earlier (<= v4.2.8) Electron versions, the window remains focused 👍
It also doesn't happen on macOS with any Electron version, the window remains focused 👍
This should now be resolved by https://github.com/electron/electron/pull/20019.
According to @nornagon, seems like this bug was reintroduced as a side effect for another fix: https://github.com/electron/electron/pull/19710#issuecomment-525945274
cc @javan
I’m working around this issue on Windows by implementing the problematic menu roles manually. Here’s a simplified version (available as a fiddle gist too):
@sofianguy, ⇡ ⇡ ⇡ this wasn’t actually Fixed in 5.0.10 or 6.0.3 and should be reopened (see my last comment above)
This is still an issue on Windows with Electron v5.0.10 and v6.0.3 which both include #19657 (the fix). Reproducible with the same fiddle I shared above.
v5.0.10
v6.0.3
Just to confirm: When I open any menu on Linux (with Electron 6) and hit ESC to close it, focus does not return to the input field. So this is a general issue for menus, not just Undo/Redo etc.