Skip to content

Conversation

@wyu71
Copy link
Contributor

@wyu71 wyu71 commented Jan 6, 2026

  • Added forceActiveFocus() call before expand to fix Tab navigation starting from wrong position after mouse click expand.

Log: ensure focus before expand in OverlapNotify
pms: BUG-339891

Summary by Sourcery

Bug Fixes:

  • Fix Tab navigation starting from the wrong position after expanding a notification via mouse click by forcing focus before expansion.

- Added forceActiveFocus() call before expand to fix Tab navigation starting from wrong position after mouse click expand.

Log: ensure focus before expand in OverlapNotify
pms: BUG-339891
@sourcery-ai
Copy link

sourcery-ai bot commented Jan 6, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Ensures the notification item gains active focus via the tap handler before triggering expand, so keyboard navigation (e.g., Tab after a mouse click) starts from the correct item.

Sequence diagram for tap handling and focus before expand in OverlapNotify

sequenceDiagram
    actor User
    participant TapHandler
    participant OverlapNotify
    participant FocusSystem
    participant NotificationContent

    User->>TapHandler: tap
    TapHandler->>OverlapNotify: forceActiveFocus()
    OverlapNotify->>FocusSystem: setActiveFocus(OverlapNotify)
    FocusSystem-->>OverlapNotify: focusConfirmed
    TapHandler->>OverlapNotify: expand()
    OverlapNotify->>NotificationContent: showExpandedView()
Loading

File-Level Changes

Change Details Files
Ensure the notification item requests active focus before expanding when clicked, to align mouse and keyboard navigation behavior.
  • Wrap TapHandler onTapped handler in a block to allow multiple statements.
  • Call root.forceActiveFocus() when the notification is tapped with the left mouse button.
  • Call root.expand() immediately after requesting active focus so behavior remains unchanged aside from focus handling.
panels/notification/center/OverlapNotify.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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider passing an explicit focus reason to forceActiveFocus() (e.g. mouse focus) if your Qt version supports it, so the focus change is correctly categorized for keyboard navigation and accessibility.
  • If there are other code paths that expand the same component via mouse/touch (beyond this TapHandler), it may be worth centralizing the forceActiveFocus() + expand() sequence in a helper to avoid inconsistent behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider passing an explicit focus reason to `forceActiveFocus()` (e.g. mouse focus) if your Qt version supports it, so the focus change is correctly categorized for keyboard navigation and accessibility.
- If there are other code paths that expand the same component via mouse/touch (beyond this `TapHandler`), it may be worth centralizing the `forceActiveFocus()` + `expand()` sequence in a helper to avoid inconsistent behavior.

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

deepin pr auto review

我来对这段代码的变更进行审查:

  1. 语法逻辑:
    代码修改在语法上是正确的,在onTapped事件处理中添加了forceActiveFocus()调用,然后执行expand()。这个修改是合理的,因为:
  • 在处理点击事件时,先确保组件获得焦点是良好的实践
  • 保持了原有的expand()功能
  • 使用了正确的大括号语法来组织多行语句
  1. 代码质量:
    这个修改提升了代码质量:
  • 改善了用户体验:确保在点击时组件能够获得焦点
  • 提高了交互的一致性:与其他键盘事件(Enter/Return)的处理保持一致
  • 代码结构清晰:使用大括号包裹多行语句,提高了可读性
  1. 代码性能:
    这个修改对性能的影响很小:
  • forceActiveFocus()是一个轻量级操作
  • 没有引入额外的计算或内存开销
  • 不会造成性能问题
  1. 代码安全:
    从安全性角度来看:
  • 修改不涉及任何安全敏感操作
  • 没有引入新的安全风险
  • forceActiveFocus()是Qt框架的标准API,使用安全

建议:

  1. 考虑在Keys.onEnterPressed和Keys.onReturnPressed事件处理中也添加forceActiveFocus(),以保持交互的一致性:
Keys.onEnterPressed: {
    root.forceActiveFocus()
    root.expand()
}
Keys.onReturnPressed: {
    root.forceActiveFocus()
    root.expand()
}
  1. 可以考虑将expand()和forceActiveFocus()的逻辑封装成一个单独的函数,以避免代码重复:
function activateAndExpand() {
    root.forceActiveFocus()
    root.expand()
}

然后在需要的地方调用这个函数。这样可以让代码更容易维护。

总的来说,这是一个好的修改,提升了用户体验和代码质量。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

@wyu71
Copy link
Contributor Author

wyu71 commented Jan 6, 2026

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Jan 6, 2026

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit d25bffe into linuxdeepin:master Jan 6, 2026
8 of 11 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