fix: improve notification center keyboard navigation#1521
Merged
wjyrich merged 1 commit intolinuxdeepin:masterfrom Mar 23, 2026
Merged
fix: improve notification center keyboard navigation#1521wjyrich merged 1 commit intolinuxdeepin:masterfrom
wjyrich merged 1 commit intolinuxdeepin:masterfrom
Conversation
Added resetFocus() function to all notification item types (GroupNotify, NormalNotify, OverlapNotify) to ensure consistent focus management. Modified focus navigation logic in NotifyView and NotifyViewDelegate to call resetFocus() before attempting to focus items. Enhanced keyboard navigation from action buttons to previous items by prioritizing close button focus when available. The changes ensure that when navigating between notification items using keyboard shortcuts, focus is properly reset to the item's main implementation before attempting to focus specific buttons. This prevents focus issues where keyboard navigation could get stuck or behave inconsistently. The onGotoPrevItem handler now checks for an enabled close button before navigating to the previous notification item, improving the user experience when navigating backward through notifications. Log: Improved keyboard navigation in notification center for better accessibility Influence: 1. Test Tab/Shift+Tab navigation between notification items 2. Verify arrow key navigation between notifications works correctly 3. Test focus behavior when moving from action buttons to previous items 4. Verify close button receives focus when navigating backward from action buttons 5. Test navigation with different notification types (group, normal, overlap) 6. Verify focus is properly reset when switching between notifications fix: 改进通知中心键盘导航 为所有通知项类型(GroupNotify、NormalNotify、OverlapNotify)添 加了resetFocus()函数,以确保一致性的焦点管理。修改了NotifyView和 NotifyViewDelegate中的焦点导航逻辑,在尝试聚焦项之前调用resetFocus()。增 强了从操作按钮到前一项的键盘导航,优先考虑关闭按钮焦点(如果可用)。 这些更改确保在使用键盘快捷键在通知项之间导航时,在尝试聚焦特定按钮之前, 焦点被正确重置到项的主实现。这防止了键盘导航可能卡住或行为不一致的焦点 问题。onGotoPrevItem处理程序现在在导航到前一个通知项之前检查启用的关闭按 钮,改善了向后浏览通知时的用户体验。 Log: 改进了通知中心的键盘导航,提升可访问性 Influence: 1. 测试Tab/Shift+Tab在通知项之间的导航 2. 验证箭头键在通知之间的导航工作正常 3. 测试从操作按钮移动到前一项时的焦点行为 4. 验证从操作按钮向后导航时关闭按钮获得焦点 5. 测试不同类型通知(群组、普通、重叠)的导航 6. 验证在通知之间切换时焦点被正确重置
Reviewer's GuideThis PR standardizes focus management across notification item types and adjusts keyboard navigation so that focus is reset to each item’s main implementation before button focusing, and backward navigation from action buttons prefers the close button when available. Sequence diagram for NotifyView focusing a notification item with resetFocussequenceDiagram
actor User
participant NotifyView
participant ListView_view as ListView_view
participant NotifyItem as NotifyItem_subclass
participant Impl as impl_component
User->>NotifyView: triggerKeyboardNavigation()
NotifyView->>ListView_view: itemAtIndex(idx)
ListView_view-->>NotifyView: NotifyItem_subclass
NotifyView->>NotifyItem: tryFocus(retries)
NotifyView->>NotifyItem: resetFocus()
NotifyItem->>Impl: forceActiveFocus()
NotifyView->>NotifyItem: focusFirstButton()
alt first button exists
NotifyItem-->>NotifyView: true
NotifyItem->>NotifyItem: firstButton.forceActiveFocus()
else no first button
NotifyItem-->>NotifyView: false
NotifyView->>NotifyItem: forceActiveFocus()
end
Sequence diagram for backward navigation from action buttons prioritizing close buttonsequenceDiagram
actor User
participant ActionButtons as ActionButtons_row
participant NotifyItemContent as NotifyItemContent_root
participant ClearLoader as clearLoader
participant CloseButton as clearLoader_item
participant NotifyView as NotifyView
User->>ActionButtons: pressShiftTabOrPrevShortcut()
ActionButtons->>NotifyItemContent: gotoPrevItem
alt close button available and enabled
NotifyItemContent->>ClearLoader: access item
ClearLoader-->>NotifyItemContent: clearLoader.item
NotifyItemContent->>CloseButton: forceActiveFocus()
else no enabled close button
NotifyItemContent->>NotifyView: gotoPrevItem()
NotifyView->>NotifyView: moveFocusToPreviousItem()
end
Class diagram for notification items and focus management changesclassDiagram
class NotifyItem {
}
class GroupNotify {
+signal gotoNextItem()
+signal gotoPrevItem()
+function resetFocus()
+function focusFirstButton()
}
class NormalNotify {
+signal gotoNextItem()
+signal gotoPrevItem()
+function resetFocus()
+function focusFirstButton()
}
class OverlapNotify {
+signal gotoNextItem()
+signal gotoPrevItem()
+property var clearButton
+function resetFocus()
+function focusFirstButton()
}
class NotifyView {
+property int idx
+function tryFocus(retries)
}
class NotifyViewDelegate {
+property int currentIndex
+function onGotoNextItem()
}
class NotifyItemContent {
+property var clearLoader
+function onGotoNextItem()
+function onGotoPrevItem()
}
class ImplComponent {
+function forceActiveFocus()
}
NotifyItem <|-- GroupNotify
NotifyItem <|-- NormalNotify
NotifyItem <|-- OverlapNotify
GroupNotify --> ImplComponent : uses impl
NormalNotify --> ImplComponent : uses impl
OverlapNotify --> ImplComponent : uses impl
NotifyView --> NotifyItem : itemAtIndex
NotifyViewDelegate --> NotifyView : view_reference
NotifyViewDelegate --> NotifyItem : nextItem
NotifyItemContent --> NotifyView : gotoNextItem\ngotoPrevItem
NotifyItemContent --> OverlapNotify : clearLoader_item_may_be_clearButton
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
NotifyView.qmlandNotifyViewDelegate.qmlyou now assume all items implementresetFocus(), so consider adding a defaultresetFocusimplementation on the baseNotifyItem(or a type check/guard) to avoid runtime errors if a different item type is ever used in the view. - The new
resetFocus()helpers callimpl.forceActiveFocus()directly; it would be safer to guard againstimplbeing null/undefined to prevent runtime errors in edge cases where the implementation component fails to load. - In
NotifyItemContent.qmltheonGotoPrevItemhandler only checksclearLoader.item && clearLoader.item.enabledbefore focusing; consider also checking visibility and focusability (e.g.visible,activeFocusOnTab) to avoid sending focus to a non-interactive or hidden close button.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `NotifyView.qml` and `NotifyViewDelegate.qml` you now assume all items implement `resetFocus()`, so consider adding a default `resetFocus` implementation on the base `NotifyItem` (or a type check/guard) to avoid runtime errors if a different item type is ever used in the view.
- The new `resetFocus()` helpers call `impl.forceActiveFocus()` directly; it would be safer to guard against `impl` being null/undefined to prevent runtime errors in edge cases where the implementation component fails to load.
- In `NotifyItemContent.qml` the `onGotoPrevItem` handler only checks `clearLoader.item && clearLoader.item.enabled` before focusing; consider also checking visibility and focusability (e.g. `visible`, `activeFocusOnTab`) to avoid sending focus to a non-interactive or hidden close button.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
18202781743
approved these changes
Mar 23, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, wjyrich The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added resetFocus() function to all notification item types (GroupNotify, NormalNotify, OverlapNotify) to ensure consistent focus management. Modified focus navigation logic in NotifyView and NotifyViewDelegate to call resetFocus() before attempting to focus items. Enhanced keyboard navigation from action buttons to previous items by prioritizing close button focus when available.
The changes ensure that when navigating between notification items using keyboard shortcuts, focus is properly reset to the item's main implementation before attempting to focus specific buttons. This prevents focus issues where keyboard navigation could get stuck or behave inconsistently. The onGotoPrevItem handler now checks for an enabled close button before navigating to the previous notification item, improving the user experience when navigating backward through notifications.
Log: Improved keyboard navigation in notification center for better accessibility
Influence:
fix: 改进通知中心键盘导航
为所有通知项类型(GroupNotify、NormalNotify、OverlapNotify)添
加了resetFocus()函数,以确保一致性的焦点管理。修改了NotifyView和
NotifyViewDelegate中的焦点导航逻辑,在尝试聚焦项之前调用resetFocus()。增 强了从操作按钮到前一项的键盘导航,优先考虑关闭按钮焦点(如果可用)。
这些更改确保在使用键盘快捷键在通知项之间导航时,在尝试聚焦特定按钮之前,
焦点被正确重置到项的主实现。这防止了键盘导航可能卡住或行为不一致的焦点
问题。onGotoPrevItem处理程序现在在导航到前一个通知项之前检查启用的关闭按
钮,改善了向后浏览通知时的用户体验。
Log: 改进了通知中心的键盘导航,提升可访问性
Influence:
Summary by Sourcery
Improve keyboard focus management and navigation between notification items in the notification center.
Bug Fixes:
Enhancements: