Repository navigation
Description
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 a feature request that matches the one I want to file, without success.
Electron Version
12.0.0
What operating system are you using?
Ubuntu
Operating System Version
20.04
What arch are you using?
x64
Last Known Working Electron version
5.x
Expected Behavior
When user change keyboard layout via Alt+Ctrl or Alt+Shift hotkeys, it should just change keyboard layout and have no effect on any focused Electron input elements.
Actual Behavior
At every layout changing on any input element (textarea, input, etc) - it lose focus, so users can't continue typing text, and need manually click on input element to restore focus and continue typing. This is very annoying for all non-English users!
Testcase Gist URL
Additional Information
How to reproduce:
-
Add any second keyboard layout in KDE settings, default hotkey for switch will be "Alt+Shift".
-
Open any app, using Electron 12.0 version, for example "Quick start" app.
-
Make focus on any input element, start typing some text.
-
Press "Alt+Shift" and try continue typing, you will can't, because element lose focus! Via "Alt" key press Electron activates app menu, and you can press "Esc" for deactivate it and continue typing, or click via mouse on element.
How to workaround:
Downgrade Electron application to 5.x or earlier versions of Electron, and this issue will not reproduced!
Right solution
Please investigate source of this issue and fix this regression on fresh Electron versions!
P.S. Here is the clone of #22213 that is closed without any reasons! Also some Electron 4.x apps was have similar issue, that can be fixed via workaround with adding keyboard shortcuts to all menu elements (here is example of fix: element-hq/element-web#4345), but this workaround stops working on Electron 6.x+ versions.
Similar reports, depending on this issue:
alt+shifttoggleswindow.menuBarVisibilityeven when the menu bar is disabled microsoft/vscode#85405- problem with "Alt+Shift" key notable/notable#557
- Changing language forces menu focus and makes it hard to write multi-language messages RocketChat/Rocket.Chat.Electron#1355
- After update, every pressing 'alt' key opens the top menu element-hq/element-web#4345
- problem with "Alt+Shift" key in electron apps #17418
- Losing focus on keyboard layout change laurent22/joplin#3345
- Cursor disappears from edit box after switching language shortcut signalapp/Signal-Desktop#4744
- Kubuntu 17.10 switching keyboard layout opens BrowserWindow menu #11106
- Can't switch keyboard layout typora/typora-issues#3366
- Alt-Shift shows the menu sindresorhus/caprine#628
- Do not show menu on pressing Alt+Shift klaudiosinani/tusk#197
- https://github.com/meetfranz/franz/issues/1366
- https://github.com/meetfranz/franz/issues/1088
- When I switch keyboard layout by Alt+Shift "Send message" input loose focus and I should click on it again everytime I switch it signalapp/Signal-Desktop#3621
- VS Code activates menu on every swich keyboard layout via Alt+Shift on Linux after 1.40 release microsoft/vscode#85444
...and many more affected apps!

Activity
MurzNN commentedon Mar 10, 2021
Possible places in code where this can be fixed:
Maybe commenting out this https://github.com/electron/electron/blob/master/shell/browser/ui/views/root_view.cc#L24-L26 section can help with workaround for this issue? I can't produce compiled Electron from source on my machine to test this, does anybody can do this test?
Other possible places are:
https://github.com/electron/electron/blob/master/shell/browser/ui/accelerator_util.cc#L46-L48
https://github.com/electron/electron/blob/master/shell/common/keyboard_util.cc#L32
https://github.com/electron/electron/blob/master/shell/browser/ui/views/global_menu_bar_x11.cc#L283
https://github.com/electron/electron/blob/master/shell/browser/ui/views/menu_bar.cc#L224
https://github.com/electron/electron/blob/master/shell/browser/ui/accelerator_util.cc#L46
https://github.com/electron/electron/blob/master/shell/browser/ui/views/root_view.cc#L25
https://github.com/electron/electron/blob/master/shell/common/keyboard_util.cc#L33
hotsezus commentedon Mar 10, 2021
There's also another issue closed
#11106 (comment)
geeksesi commentedon Mar 16, 2021
i found something.
if you press alt (first and don't release ) + shift ( pres and release then release alt ). there is no problem.
but my habit is this : press alt ( first and don't release ) + press shift and release alt then release shift.
we should change shift action to press ( now will act to shift when you release it ). ( i think can't do this )
just make an event for ( presed alt + presed shift ) and prevent it to default ¯_(ツ)_/¯
isaacvonaaron commentedon Mar 24, 2021
Just want to upvote on this and say it's very important and affects users from most of the world except north America and part of western Europe. The rest of the world needs to switch between input methods quite often.
koshelevdk commentedon Apr 8, 2021
Same issue is relevant for Slack (messenger) and Atom (text editor). For slack we have web version at least. But other applications are completely useless.
wlwl2 commentedon Apr 9, 2021
This Alt key ambiguity can affect all Alt- key shortcuts as well (I've had to remove my old shortcuts), and I'm working primarily in English right now. I've raised some points here:
atom/atom#21825 (comment)
One solution might be to separate Electron/Atom Alt key from the operating system Alt key. I'm also not sure at which point KeyDown, KeyUp and KeyPress is currently controlled. I wonder if that is done in Electron or Atom's codebase.
MurzNN commentedon May 17, 2021
Still the very annoying issue on Electron 13.0 beta too, for all users, that user more than one keyboard layouts with default switch hotkey!
PanosFirmpas commentedon May 17, 2021
Commenting to add pressure for the issue to be fixed.
vetash commentedon May 24, 2021
This is noncence, after all these years there is no any reaction for this bug! Just great. I decided to remove all menu in any electron based app on my desktop becaouse of this rubbish, thank you opensource, great job, Still not have any clue for how this can been happen AGAIN after some devs workaround this bug in 2017. element-hq/element-web@0cf16be
MurzNN commentedon Jun 28, 2021
@zcbenz Can you please commend in which Electron release this PR is included? I testing app with Electron 13.0.1 (Chrome 91.0.4472.69) on KDE 5.22.0 (KDE Frameworks Version: 5.82.0) - the problem is still persist!
But your PR integrated into VS Code (even for 12.x electron version) works well: microsoft/vscode#85405 (comment)
MurzNN commentedon Jun 28, 2021
Seems this fix is included in 13.1.0 version only: https://www.electronjs.org/releases/stable?page=1#13.1.0 - will wait...