From 2f8526c4c86d21a0935393690885cf4b93a6f3f2 Mon Sep 17 00:00:00 2001 From: Wu JiangYu Date: Mon, 30 Nov 2026 17:58:18 +0800 Subject: [PATCH] fix(dock): prevent overflow popup closing on app context menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Add a contextMenuGuard callback to AppItem to signal context menu state 2. Notify TaskOverflowButton when an app context menu opens or hides 3. Use the guard flag to keep the overflow popup open while a menu is active Log: Keep the task overflow popup open when an app context menu is shown Influence: Prevents overflow popup from closing unexpectedly on right- click fix(dock): 修复右键菜单导致任务溢出弹窗关闭 1. 为 AppItem 增加 contextMenuGuard 回调以传递右键菜单状态 2. 应用右键菜单显示或隐藏时通知 TaskOverflowButton 3. 使用该标志避免菜单激活期间关闭溢出弹窗 Log: 避免应用右键菜单显示时任务溢出弹窗被意外关闭 Influence: 防止右键操作时溢出弹窗意外关闭 PMS: BUG-384793 --- panels/dock/taskmanager/package/AppItem.qml | 7 +++++++ panels/dock/taskmanager/package/TaskOverflowButton.qml | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/panels/dock/taskmanager/package/AppItem.qml b/panels/dock/taskmanager/package/AppItem.qml index 7132ed2f1..864bdfd28 100644 --- a/panels/dock/taskmanager/package/AppItem.qml +++ b/panels/dock/taskmanager/package/AppItem.qml @@ -78,6 +78,7 @@ Item { property bool enableTitle: false property bool titleActive: enableTitle && titleLoader.active property bool preservePanelPopupOnContextMenu: false + property var contextMenuGuard: null property bool updateIconGeometry: true property Item previewAnchor: icon // Folder content replaces the overflow popup, so anchor it to the dock. @@ -504,6 +505,10 @@ Item { property bool trashEmpty: true sourceComponent: LP.Menu { id: contextMenu + onAboutToHide: Qt.callLater(function() { + if (MenuHelper.activeMenu === null && root.contextMenuGuard) + root.contextMenuGuard(false) + }) Instantiator { id: menuItemInstantiator model: JSON.parse(menus) @@ -596,6 +601,8 @@ Item { } function requestAppItemMenu() { + if (root.contextMenuGuard) + root.contextMenuGuard(true) if (!root.preservePanelPopupOnContextMenu) { Panel.requestClosePopup() } diff --git a/panels/dock/taskmanager/package/TaskOverflowButton.qml b/panels/dock/taskmanager/package/TaskOverflowButton.qml index 3ee28275b..389eed8b1 100644 --- a/panels/dock/taskmanager/package/TaskOverflowButton.qml +++ b/panels/dock/taskmanager/package/TaskOverflowButton.qml @@ -45,6 +45,7 @@ Item { readonly property int popupColumns: Math.min(6, Math.max(1, overflowCount), Math.max(1, Math.floor((popupAvailableWidth - 20) / popupCellWidth))) property point popupAnchorPoint: Qt.point(0, 0) + property bool contextMenuActive: false visible: overflowCount > 0 && overflow.buttonExtent > 0 x: root.taskManagerItem.useColumnLayout ? 0 : root.buttonOffset @@ -136,6 +137,10 @@ Item { overflowPopup.open() } + function guardContextMenu(active) { + contextMenuActive = active + } + AppItemBackground { width: root.hoverBackgroundWidth height: root.hoverBackgroundHeight @@ -220,7 +225,8 @@ Item { contentReady: popupContentLoader.status === Loader.Ready popupX: DockPanelPositioner.x popupY: DockPanelPositioner.y - closeOnInactive: MenuHelper.activeMenu === null && !Panel.contextDragging + closeOnInactive: !root.contextMenuActive + && MenuHelper.activeMenu === null && !Panel.contextDragging Component.onCompleted: { DockPanelPositioner.bounding = Qt.binding(function () { @@ -307,6 +313,7 @@ Item { title: popupDelegate.entry.title enableTitle: false preservePanelPopupOnContextMenu: true + contextMenuGuard: root.guardContextMenu previewAnchor: overflowPopupContent folderAnchor: root updateIconGeometry: false