From acce13234efdc0e892ee5b8903393295e488f935 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 27 May 2021 09:36:15 +0900 Subject: [PATCH] fix: close autoHide menu bar when focus is lost (#29320) --- shell/browser/ui/views/menu_bar.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shell/browser/ui/views/menu_bar.cc b/shell/browser/ui/views/menu_bar.cc index b3ba04d12178..d4304403393e 100644 --- a/shell/browser/ui/views/menu_bar.cc +++ b/shell/browser/ui/views/menu_bar.cc @@ -124,7 +124,10 @@ bool MenuBar::AcceleratorPressed(const ui::Accelerator& accelerator) { ? ui::Accelerator(ui::VKEY_ESCAPE, accelerator.modifiers(), accelerator.key_state(), accelerator.time_stamp()) : accelerator; - return views::AccessiblePaneView::AcceleratorPressed(translated); + bool result = views::AccessiblePaneView::AcceleratorPressed(translated); + if (result && !pane_has_focus()) + root_view_->RestoreFocus(); + return result; } bool MenuBar::SetPaneFocusAndFocusDefault() { @@ -149,6 +152,8 @@ void MenuBar::OnThemeChanged() { void MenuBar::OnDidChangeFocus(View* focused_before, View* focused_now) { views::AccessiblePaneView::OnDidChangeFocus(focused_before, focused_now); SetAcceleratorVisibility(pane_has_focus()); + if (!pane_has_focus()) + root_view_->RestoreFocus(); } const char* MenuBar::GetClassName() const {