sc/source/ui/cctrl/checklistmenu.cxx | 17 +++++++++++++---- sc/source/ui/inc/checklistmenu.hxx | 2 ++ sc/source/ui/view/gridwin.cxx | 1 + 3 files changed, 16 insertions(+), 4 deletions(-)
New commits: commit ac41defa75365451db264379c514993679618208 Author: Caolán McNamara <[email protected]> AuthorDate: Fri Jan 28 09:58:05 2022 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jan 28 21:35:08 2022 +0100 Resolves: tdf#147016 ensure focus returns to document after popup closes Change-Id: I67e59afc08bc5983d473cb9dceb4fcefedeec117 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129094 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sc/source/ui/cctrl/checklistmenu.cxx b/sc/source/ui/cctrl/checklistmenu.cxx index 0d4a3857d34f..52f53a34838e 100644 --- a/sc/source/ui/cctrl/checklistmenu.cxx +++ b/sc/source/ui/cctrl/checklistmenu.cxx @@ -299,6 +299,8 @@ void ScCheckListMenuControl::queueCloseSubMenu() maCloseTimer.mpSubMenu = maOpenTimer.mpSubMenu; maCloseTimer.mnMenuPos = maOpenTimer.mnMenuPos; + maOpenTimer.mpSubMenu = nullptr; + maOpenTimer.mnMenuPos = MENU_NOT_SELECTED; maCloseTimer.maTimer.Start(); } @@ -586,11 +588,8 @@ void ScCheckListMenuControl::GrabFocus() } } -ScCheckListMenuControl::~ScCheckListMenuControl() +void ScCheckListMenuControl::DropPendingEvents() { - EndPopupMode(); - for (auto& rMenuItem : maMenuItems) - rMenuItem.mxSubMenuWin.reset(); if (mnAsyncPostPopdownId) { Application::RemoveUserEvent(mnAsyncPostPopdownId); @@ -603,6 +602,14 @@ ScCheckListMenuControl::~ScCheckListMenuControl() } } +ScCheckListMenuControl::~ScCheckListMenuControl() +{ + EndPopupMode(); + for (auto& rMenuItem : maMenuItems) + rMenuItem.mxSubMenuWin.reset(); + DropPendingEvents(); +} + void ScCheckListMenuControl::prepWindow() { mxMenu->set_size_request(-1, mxMenu->get_preferred_size().Height() + 2); @@ -1472,6 +1479,8 @@ IMPL_LINK_NOARG(ScCheckListMenuControl, PopupModeEndHdl, weld::Popover&, void) if (mxPopupEndAction) mxPopupEndAction->execute(); + DropPendingEvents(); + if (comphelper::LibreOfficeKit::isActive()) NotifyCloseLOK(); } diff --git a/sc/source/ui/inc/checklistmenu.hxx b/sc/source/ui/inc/checklistmenu.hxx index 87a3e4325e45..31d5a5b97fde 100644 --- a/sc/source/ui/inc/checklistmenu.hxx +++ b/sc/source/ui/inc/checklistmenu.hxx @@ -255,6 +255,8 @@ private: void ResizeToRequest(); + void DropPendingEvents(); + private: std::unique_ptr<weld::Builder> mxBuilder; std::unique_ptr<weld::Popover> mxPopover; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 2404ea47dd29..1bc40626c81a 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -526,6 +526,7 @@ public: virtual bool execute() override { mpWindow->RefreshAutoFilterButton(maPos); + mpWindow->GrabFocus(); return false; // this is called after the popup has been closed } };
