Skip to content

fix: prevent disabled menu items from highlighting - #763

Merged
18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master
Dec 3, 2026
Merged

18202781743 merged 1 commit into
linuxdeepin:masterfrom
18202781743:master

Conversation

@18202781743

@18202781743 18202781743 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor
  1. Add enabled check to highlighted property so disabled menu items
    never enter highlighted state
  2. Update textColor binding to only use highlighted text color when the
    control is both enabled and highlighted
  3. Gate the highlight panel Loader activation on enabled state to avoid
    rendering hover visuals for disabled items

Influence:

  1. Open a menu containing both enabled and disabled items and verify
    disabled items do not highlight on hover
  2. Verify enabled items still highlight correctly on hover and when
    their submenu is visible
  3. Check that disabled item text remains in the normal (non-highlighted)
    color when hovered
  4. Confirm no highlight panel renders behind disabled items during hover
  5. Test submenu open/close behavior on enabled items is unaffected
  6. Verify opacity for disabled items stays consistent at 0.4

fix: 禁止禁用状态的菜单项显示高亮

  1. 在 highlighted 属性中加入 enabled 判断,确保禁用的菜单项不会进入高亮
    状态
  2. 更新 textColor 绑定,仅在控件同时处于启用和高亮状态时使用高亮文字颜色
  3. 高亮面板 Loader 的激活条件加入 enabled 判断,避免为禁用项渲染悬停视觉
    效果

Influence:

  1. 打开包含启用和禁用项的菜单,验证禁用项悬停时不高亮
  2. 验证启用项在悬停及子菜单可见时仍能正确高亮
  3. 检查禁用项文字在悬停时保持普通(非高亮)颜色
  4. 确认禁用项悬停时不会渲染高亮面板
  5. 测试启用项的子菜单打开/关闭行为不受影响
  6. 验证禁用项透明度保持为 0.4

Log: Fixed disabled menu items incorrectly showing highlight on hover
PMS: BUG-380835

Summary by Sourcery

Bug Fixes:

  • Prevent disabled menu items from entering the highlighted state or showing highlighted text and hover-panel visuals.

1. Add enabled check to highlighted property so disabled menu items
never enter highlighted state
2. Update textColor binding to only use highlighted text color when the
control is both enabled and highlighted
3. Gate the highlight panel Loader activation on enabled state to avoid
rendering hover visuals for disabled items

Influence:
1. Open a menu containing both enabled and disabled items and verify
disabled items do not highlight on hover
2. Verify enabled items still highlight correctly on hover and when
their submenu is visible
3. Check that disabled item text remains in the normal (non-highlighted)
color when hovered
4. Confirm no highlight panel renders behind disabled items during hover
5. Test submenu open/close behavior on enabled items is unaffected
6. Verify opacity for disabled items stays consistent at 0.4

fix: 禁止禁用状态的菜单项显示高亮

1. 在 highlighted 属性中加入 enabled 判断,确保禁用的菜单项不会进入高亮
状态
2. 更新 textColor 绑定,仅在控件同时处于启用和高亮状态时使用高亮文字颜色
3. 高亮面板 Loader 的激活条件加入 enabled 判断,避免为禁用项渲染悬停视觉
效果

Influence:
1. 打开包含启用和禁用项的菜单,验证禁用项悬停时不高亮
2. 验证启用项在悬停及子菜单可见时仍能正确高亮
3. 检查禁用项文字在悬停时保持普通(非高亮)颜色
4. 确认禁用项悬停时不会渲染高亮面板
5. 测试启用项的子菜单打开/关闭行为不受影响
6. 验证禁用项透明度保持为 0.4

Log: Fixed disabled menu items incorrectly showing highlight on hover
PMS: BUG-380835
@18202781743
18202781743 requested review from BLumia and mhduiy December 3, 2026 05:02
@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

UI

Prevent disabled menu items from entering the highlighted state, using highlighted text color, or rendering the highlight panel.

  • qt6/src/qml/MenuItem.qml L20, L26-27, L107

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="qt6/src/qml/MenuItem.qml" line_range="20" />
<code_context>
     spacing: DS.Style.control.spacing
     opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1
-    highlighted: hovered || (subMenu && subMenu.visible)
+    highlighted: enabled && (hovered || (subMenu && subMenu.visible))
     icon {
         height: DS.Style.menu.item.iconSize.height
</code_context>
<issue_to_address>
**Disabled combo items remain highlighted**

When a disabled ComboBox entry is the current `highlightedIndex`, `ComboBox.delegate` replaces this binding with `highlightedIndex === index` (or `false`), so a disabled item that is the current highlighted index still reports `highlighted: true`. The added text-color and panel guards hide those visuals but do not prevent the highlighted state from reaching callers.

Include the delegate's enabled state in the ComboBox `highlighted` binding, or otherwise ensure the enabled check also applies to that override.
</issue_to_address>

### Comment 2
<location path="qt6/src/qml/MenuItem.qml" line_range="20" />
<code_context>
     spacing: DS.Style.control.spacing
     opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1
-    highlighted: hovered || (subMenu && subMenu.visible)
+    highlighted: enabled && (hovered || (subMenu && subMenu.visible))
     icon {
         height: DS.Style.menu.item.iconSize.height
</code_context>
<issue_to_address>
**Disabled items still highlight on Qt 5**

When the project is built against Qt 5 and a disabled menu item is hovered, a Qt 5 build uses the unchanged `src/qml/MenuItem.qml`, where `highlighted` is not gated by `enabled` and the highlight Loader activates for `control.highlighted`. Hovering a disabled item therefore still shows highlight visuals and highlighted text.

Apply the enabled checks to the Qt 5 `src/qml/MenuItem.qml` implementation as well.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread qt6/src/qml/MenuItem.qml Resolved
Comment thread qt6/src/qml/MenuItem.qml Resolved
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, BLumia

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@18202781743
18202781743 merged commit 7376e1f into linuxdeepin:master Dec 3, 2026
7 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants