Skip to content

Conversation

@18202781743
Copy link
Contributor

@18202781743 18202781743 commented Sep 22, 2025

The changes address the tab key navigation issue in the notification
center where pressing tab couldn't close notifications. The main fix
involves converting NotifyItem from Control to FocusScope to properly
handle focus management. Additionally, all notification components
(GroupNotify, NormalNotify, OverlapNotify, NotifyItemContent) were
wrapped in Control containers with proper implicit size properties to
ensure consistent focus behavior. The close button visibility logic was
updated to use activeFocus instead of hovered state for better keyboard
navigation support.

Log: Fixed tab key navigation issue in notification center

Influence:

  1. Test tab navigation through notification items
  2. Verify close button appears with keyboard focus
  3. Test Enter/Return key functionality on notifications
  4. Verify mouse interactions still work correctly
  5. Test notification dismissal with keyboard shortcuts

fix: 修复通知中心Tab键焦点问题

此次修改解决了通知中心中按Tab键无法关闭通知的问题。主要修复包括将
NotifyItem从Control转换为FocusScope以正确处理焦点管理。此外,所有通知组
件(GroupNotify、NormalNotify、OverlapNotify、NotifyItemContent)都被包
装在Control容器中,并设置了适当的隐式大小属性以确保一致的焦点行为。关闭
按钮的可见性逻辑更新为使用activeFocus而不是hovered状态,以提供更好的键盘
导航支持。

Log: 修复通知中心Tab键导航问题

Influence:

  1. 测试通过通知项的Tab导航
  2. 验证关闭按钮是否随键盘焦点出现
  3. 测试Enter/Return键在通知上的功能
  4. 验证鼠标交互是否仍然正常工作
  5. 测试使用键盘快捷键关闭通知

PMS: BUG-311333

Summary by Sourcery

Improve keyboard navigation in the notification center by refactoring focus management, wrapping components for consistent sizing, and updating close button visibility logic to support Tab and Enter/Return key interactions

New Features:

  • Support expanding overlapping notifications via Enter/Return keys

Enhancements:

  • Convert NotifyItem root element from Control to FocusScope for improved focus management
  • Wrap all notification components in Control containers with implicit size properties for consistent focus behavior
  • Update close button visibility logic to depend on activeFocus instead of hovered for keyboard navigation

The changes address the tab key navigation issue in the notification
center where pressing tab couldn't close notifications. The main fix
involves converting NotifyItem from Control to FocusScope to properly
handle focus management. Additionally, all notification components
(GroupNotify, NormalNotify, OverlapNotify, NotifyItemContent) were
wrapped in Control containers with proper implicit size properties to
ensure consistent focus behavior. The close button visibility logic was
updated to use activeFocus instead of hovered state for better keyboard
navigation support.

Log: Fixed tab key navigation issue in notification center

Influence:
1. Test tab navigation through notification items
2. Verify close button appears with keyboard focus
3. Test Enter/Return key functionality on notifications
4. Verify mouse interactions still work correctly
5. Test notification dismissal with keyboard shortcuts

fix: 修复通知中心Tab键焦点问题

此次修改解决了通知中心中按Tab键无法关闭通知的问题。主要修复包括将
NotifyItem从Control转换为FocusScope以正确处理焦点管理。此外,所有通知组
件(GroupNotify、NormalNotify、OverlapNotify、NotifyItemContent)都被包
装在Control容器中,并设置了适当的隐式大小属性以确保一致的焦点行为。关闭
按钮的可见性逻辑更新为使用activeFocus而不是hovered状态,以提供更好的键盘
导航支持。

Log: 修复通知中心Tab键导航问题

Influence:
1. 测试通过通知项的Tab导航
2. 验证关闭按钮是否随键盘焦点出现
3. 测试Enter/Return键在通知上的功能
4. 验证鼠标交互是否仍然正常工作
5. 测试使用键盘快捷键关闭通知

PMS: BUG-311333
@sourcery-ai
Copy link

sourcery-ai bot commented Sep 22, 2025

Reviewer's Guide

This PR refactors focus and keyboard navigation in the notification center by converting NotifyItem to a FocusScope root, wrapping notification content in Control containers with implicit sizing, switching close button visibility to rely on activeFocus, adding Enter/Return key handlers for expansion, and fixing a border radius reference.

Sequence diagram for notification close button visibility logic change

sequenceDiagram
    participant User as actor
    participant NotifyItemContent
    participant CloseButton
    User->>NotifyItemContent: Tab to notification item
    NotifyItemContent->>CloseButton: Set visible if activeFocus
    User->>CloseButton: Press Enter/Return to close notification
    CloseButton->>NotifyItemContent: Trigger remove/dismiss
Loading

Updated class diagram for notification components focus management

classDiagram
    class NotifyItem {
        <<FocusScope>>
        +enum CloseReason
        // Now inherits FocusScope instead of Control
    }
    class NotifyItemContent {
        +bool closeVisible (now uses activeFocus)
        +int miniContentHeight
        +bool enableDismissed
        +implicitWidth
        +implicitHeight
        // Wrapped in Control for focus/size
    }
    class GroupNotify {
        +implicitWidth
        +implicitHeight
        // Wrapped in Control for focus/size
    }
    class NormalNotify {
        +implicitWidth
        +implicitHeight
        // Wrapped in Control for focus/size
    }
    class OverlapNotify {
        +implicitWidth
        +implicitHeight
        // Wrapped in Control for focus/size
    }
    NotifyItem <|-- NotifyItemContent
    NotifyItem <|-- GroupNotify
    NotifyItem <|-- NormalNotify
    NotifyItem <|-- OverlapNotify
    NotifyItemContent o-- Control
    GroupNotify o-- Control
    NormalNotify o-- Control
    OverlapNotify o-- Control
Loading

File-Level Changes

Change Details Files
Convert NotifyItem root to FocusScope for proper focus management
  • Replaced Control with FocusScope as the root element in NotifyItem.qml
panels/notification/plugin/NotifyItem.qml
Wrap notification components in Control containers with implicit sizing
  • Introduced a Control wrapper (id impl) around contentItem
  • Bound implicitWidth/implicitHeight to impl.implicitWidth/implicitHeight
  • Scoped palette and theme references through impl
panels/notification/plugin/NotifyItemContent.qml
panels/notification/center/OverlapNotify.qml
panels/notification/center/GroupNotify.qml
panels/notification/center/NormalNotify.qml
Update close button behavior to use keyboard focus
  • Changed closeVisible property to rely on activeFocus instead of hovered
  • Enabled focus:true on the close button Loader
panels/notification/plugin/NotifyItemContent.qml
Add keyboard expansion shortcuts to OverlapNotify
  • Added Keys.onEnterPressed and onReturnPressed handlers to trigger expand()
panels/notification/center/OverlapNotify.qml
Fix border radius reference in NotifyViewDelegate
  • Updated the radius property to use overlapItemRadius instead of overlapNotify.radius
panels/notification/center/NotifyViewDelegate.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 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.

@18202781743 18202781743 changed the title ] fix: Fixed tab key navigation issue in notification center Sep 22, 2025
@deepin-ci-robot
Copy link

[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
Copy link
Contributor Author

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Sep 22, 2025

This pr force merged! (status: blocked)

@deepin-bot deepin-bot bot merged commit c5213d4 into linuxdeepin:master Sep 22, 2025
6 of 8 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