New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undo/Redo/Cut/Copy/Paste & more Not work using Menubar in Windows #18745
Comments
cc @felixrieseberg, perhaps this is a fiddle issue? |
My app has the same problems, so I don't think it's just a fiddle problem. Also, these "role" based menu behaviours are provided by Electron, not by application code. |
I did some more investigation and can reproduce all problems with Electron API Demo. Current version uses Electron@4, so upgrade to Electron@5 as follows: To Reproduce $ git clone https://github.com/electron/electron-api-demos Edit package.json to update electron version $ npm install In the app go to System > Copy & paste from the clipboard Use the provided text field to test: Undo/Redo/Cut/Copy/Paste/SelectAll Observations In Electron@5, when click on menubar, keyboard focus disappears from text field, doesn't work. But this doesn't explain failure of ZoomIn/ZoomOut/ResetZoom, as follows. ** To Reproduce ** API Demo doesn't include zoom function so add. Add to any menu: Observations In Electron@5, Zoom functions don't work from menubar with mouse, but work fine using keyboard shortcuts. |
Is not this the same as #15219? Looks like it's not but might be related. |
It seems to be the same as #18518 and it's not confined to Windows. I experienced the same issue running Linux. As far as I can see, there is a change in the behaviour of the menu that seems to steel the focus from the WebView. In consequence the actions have no effect. See my comment for a workaround (which only applies under certain circumstances). Clearly a regression to 4.x. |
I can confirm that the following roles do not work on Windows with Electron v5.0.8 and v6.0.0:
Here's a fiddle gist: https://gist.github.com/javan/69c1075d389acd5a3437c6459e4c6a6d The underlying issue may be the window losing focus (as noted in #18518), which appears to happen when you interact with the menu. |
To clarify, I only used a fiddle URL above because it's the easiest way to share an app that reproduces the issue. The issue itself is not related to fiddle. |
Can confirm that this is occurring for me on Ubuntu 19.04 as well. Investigating. 🕵️♂️ Update
Update |
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. |
@sofianguy, ⇡ ⇡ ⇡ this wasn't actually Fixed in 5.0.10 or 6.0.3 and should be reopened (see my last comment above) |
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): const isWindows = process.platform == "win32"
const template = [
{
label: "Edit",
submenu: isWindows ? [
{ label: "Undo", click: focusAndPerform("undo"), accelerator: "Ctrl+Z" },
{ label: "Redo", click: focusAndPerform("redo"), accelerator: "Ctrl+Shift+Z" },
{ label: "Cut", click: focusAndPerform("cut"), accelerator: "Ctrl+X" },
{ label: "Copy", click: focusAndPerform("copy"), accelerator: "Ctrl+C" },
{ label: "Paste", click: focusAndPerform("paste"), accelerator: "Ctrl+V" },
] : [
{ role: "undo" },
{ role: "redo" },
{ role: "cut" },
{ role: "copy" },
{ role: "paste" },
]
}
]
function focusAndPerform(methodName) {
return function(menuItem, window) {
window.webContents.focus()
window.webContents[methodName]()
}
} |
According to @nornagon, seems like this bug was reintroduced as a side effect for another fix: #19710 (comment) cc @javan |
This should now be resolved by #20019. |
It is not working. undo, redo, copy, paste roles do not work using Electron ^5.0.10 on Ubuntu 18.04 |
Still not working on Ubuntu 16.04 LTS and Electron 12.0.0 |
Preflight Checklist
Issue Details
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:
Electron Fiddle does the same:
https://github.com/electron/fiddle/blob/88ce4a76e97c4c93821306b59b3de9a147378058/src/main/menu.ts
The text was updated successfully, but these errors were encountered: