### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) 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

https://github.com/geeksesi/time_reminder

### Additional Information

**How to reproduce:**

1. Add any second keyboard layout in KDE settings, default hotkey for switch will be "Alt+Shift".

2. Open any app, using Electron 12.0 version, for example "Quick start" app.

3. Make focus on any input element, start typing some text.

4. 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.

Screenshot of problem:
![](https://user-images.githubusercontent.com/28778964/54477533-03b62c00-481e-11e9-8c63-3c1f7402eaa5.png)

**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: https://github.com/vector-im/riot-web/issues/4345), but this workaround stops working on Electron 6.x+ versions.

**_Similar reports, depending on this issue:_** 
- https://github.com/microsoft/vscode/issues/85405
- https://github.com/notable/notable/issues/557 
- https://github.com/RocketChat/Rocket.Chat.Electron/issues/1355
- https://github.com/vector-im/element-web/issues/4345
- https://github.com/electron/electron/issues/17418
- https://github.com/laurent22/joplin/issues/3345
- https://github.com/signalapp/Signal-Desktop/issues/4744
- https://github.com/electron/electron/issues/11106
- https://github.com/typora/typora-issues/issues/3366
- https://github.com/sindresorhus/caprine/issues/628
- https://github.com/klaussinani/tusk/pull/197
- https://github.com/meetfranz/franz/issues/1366
- https://github.com/meetfranz/franz/issues/1088
- https://github.com/signalapp/Signal-Desktop/issues/3621
- https://github.com/microsoft/vscode/issues/85444
...and many more affected apps!
shell/browser/ui/views/root_view.cc
if (!window_->content_view() || !menu_bar_ || menu_bar_visible_ == visible)
    return;
  menu_bar_visible_ = visible;
  if (visible) {
    DCHECK_EQ(children().size(), 1ul);
    AddChildView(menu_bar_.get());
  } else {
    DCHECK_EQ(children().size(), 2ul);
    RemoveChildView(menu_bar_.get());
  }
  Layout();
}
bool RootView::IsMenuBarVisible() const {
  return menu_bar_visible_;
}
void RootView::HandleKeyEvent(const content::NativeWebKeyboardEvent& event) {
  if (!menu_bar_)
    return;
  
  if (menu_bar_visible_ && IsAltKey(event))
    menu_bar_->SetAcceleratorVisibility(
        event.GetType() == blink::WebInputEvent::Type::kRawKeyDown);
  
  if (event.GetType() == blink::WebInputEvent::Type::kRawKeyDown &&
      !IsAltKey(event) && IsAltModifier(event)) {
    if (menu_bar_->HasAccelerator(event.windows_key_code)) {
      if (!menu_bar_visible_) {
        SetMenuBarVisibility(true);
        View* focused_view = GetFocusManager()->GetFocusedView();
        last_focused_view_tracker_->SetView(focused_view);