From 33d6d9858abaedd3df9d33f5765426bd02f1e1e8 Mon Sep 17 00:00:00 2001 From: electricface Date: Tue, 10 Mar 2026 15:58:04 +0800 Subject: [PATCH] fix(ComboBox): fix highlight lingering after mouse leaves MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Track the popup's hover state by adding a isInteractingWithContent property to ComboBox, and modify the highlighted property in the delegate. - The logic of the highlighted property now depends on isInteractingWithContent, automatically clearing the highlight when the mouse leaves. 修复鼠标移出后高亮项仍然残留的问题 - 在ComboBox上添加isInteractingWithContent属性跟踪popup悬停状态,修改delegate的highlighted属性 - highlighted属性逻辑依赖isInteractingWithContent,鼠标离开时自动清除高亮 Log: 修复ComboBox的菜单项鼠标离开后高亮残留问题 Influence: ComboBox菜单项 PMS: BUG-304991 --- qt6/src/qml/ComboBox.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/qt6/src/qml/ComboBox.qml b/qt6/src/qml/ComboBox.qml index 2463968f..3ee97457 100644 --- a/qt6/src/qml/ComboBox.qml +++ b/qt6/src/qml/ComboBox.qml @@ -19,6 +19,7 @@ T.ComboBox { property int maxVisibleItems : DS.Style.comboBox.maxVisibleItems property D.Palette separatorColor: DS.Style.comboBox.edit.separator property var horizontalAlignment: control.flat ? Text.AlignRight : Text.AlignLeft + property bool isInteractingWithContent: false opacity: enabled ? 1.0 : 0.4 implicitWidth: DS.Style.control.implicitWidth(control) @@ -36,7 +37,7 @@ T.ComboBox { useIndicatorPadding: true text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : (model[control.textRole] === undefined ? modelData[control.textRole] : model[control.textRole])) : modelData icon.name: (control.iconNameRole && model[control.iconNameRole] !== undefined) ? model[control.iconNameRole] : null - highlighted: control.highlightedIndex === index + highlighted: control.isInteractingWithContent ? control.highlightedIndex === index : false hoverEnabled: control.hoverEnabled autoExclusive: true checked: control.currentIndex === index @@ -169,6 +170,17 @@ T.ComboBox { rightMargin: DS.Style.popup.margin palette: control.palette implicitWidth: control.flat ? Math.max(contentItem.implicitWidth, control.width) : control.width + onClosed: control.isInteractingWithContent = false + Connections { + target: control + function onHighlightedIndexChanged() { + if (control.highlightedIndex >= 0) + control.isInteractingWithContent = true + } + } + HoverHandler { + onHoveredChanged: control.isInteractingWithContent = hovered + } contentItem: ArrowListView { clip: true maxVisibleItems: control.maxVisibleItems