Skip to content

fix: avoid keyboard focus on menu that not visible#663

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:pms-338173
Oct 24, 2025
Merged

fix: avoid keyboard focus on menu that not visible#663
BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:pms-338173

Conversation

@BLumia

@BLumia BLumia commented Oct 24, 2025

Copy link
Copy Markdown
Member

避免键盘焦点选中不可见的菜单项。

Summary by Sourcery

Disable invisible menu items to prevent unintended keyboard focus and clean up minor whitespace

Bug Fixes:

  • Disable keyboard focus on menu items that are not visible by binding enabled to the visible state

Chores:

  • Remove trailing whitespace from a function call

避免键盘焦点选中不可见的菜单项。

PMS: BUG-338173 Log:
@BLumia BLumia requested a review from wjyrich October 24, 2025 02:15
@sourcery-ai

sourcery-ai Bot commented Oct 24, 2025

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Bind the MenuItem enabled state to its visibility to block keyboard focus on hidden items, along with a minor whitespace cleanup.

Class diagram for updated MenuItem enabled binding

classDiagram
    class MenuItem {
        visible : bool
        enabled : bool
        height : int
        text : string
        onTriggered()
    }
    class moveToTopMenu {
        enabled = visible
        height = visible ? implicitHeight : 0
    }
    MenuItem <|-- moveToTopMenu
Loading

File-Level Changes

Change Details Files
Prevent invisible menu items from gaining keyboard focus
  • Add enabled: visible binding to menu item
  • Ensure hidden items are disabled
qml/AppItemMenu.qml
Clean up trailing whitespace
  • Remove extra space after setAvoidHide(false) call
qml/AppItemMenu.qml

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 there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

我来帮你审查这段代码的变更。这段代码包含两处修改:

  1. 在 moveToTopMenu MenuItem 中添加了 enabled: visible 属性
  2. 删除了一行末尾的空格

让我从多个角度分析这段代码:

  1. 语法逻辑:
  • 添加 enabled: visible 是合理的,这确保了当菜单项不可见时,它也会被禁用。这样可以防止用户通过键盘导航等方式访问不可见的菜单项。
  • 语法正确,符合 QML 的属性绑定语法规范。
  1. 代码质量:
  • 这是一个很好的改进,增强了用户体验和交互的严谨性。
  • 保持了与其他代码风格的一致性。
  • 删除末尾空格有助于保持代码整洁,符合良好的代码规范。
  1. 代码性能:
  • 这个修改对性能影响微乎其微,因为 visible 属性的变化会触发 enabled 属性的重新计算,但这是一个非常轻量级的操作。
  • 不存在性能问题。
  1. 代码安全:
  • 这个修改提高了代码的安全性,防止了不可见菜单项被意外触发的情况。
  • 没有引入任何安全风险。

改进建议:

  1. 考虑为其他类似的 MenuItem 也添加相同的 enabled: visible 属性,以保持整个菜单的一致性。
  2. 建议在代码审查规范中添加关于末尾空格的检查,以避免类似问题。

总的来说,这是一个很好的改进,提高了代码的健壮性和用户体验。修改简单但有效,没有任何负面影响。

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@BLumia BLumia merged commit fde7a73 into linuxdeepin:master Oct 24, 2025
8 of 10 checks passed
@BLumia BLumia deleted the pms-338173 branch October 24, 2025 02:30
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