-
Notifications
You must be signed in to change notification settings - Fork 55
fix: resolve Tab key focus navigation issues in notification center #1369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,13 @@ FocusScope { | |
| width: NotifyStyle.contentItem.width | ||
| notifyModel: notifyModel | ||
| z: 1 | ||
| onGotoFirstNotify: { | ||
| if (view.viewCount === 0 || !view.focusItemAtIndex(0)) header.focusFirstButton() | ||
|
Comment on lines
+39
to
+40
|
||
| } | ||
| onGotoLastNotify: { | ||
| if (view.viewCount === 0) header.focusLastButton() | ||
| else view.focusLastItem() | ||
| } | ||
| } | ||
|
|
||
| NotifyView { | ||
|
|
@@ -51,6 +58,8 @@ FocusScope { | |
|
|
||
| height: Math.min(maxViewHeight, viewHeight) | ||
| notifyModel: notifyModel | ||
| onGotoHeaderFirst: header.focusFirstButton() | ||
| onGotoHeaderLast: header.focusLastButton() | ||
| } | ||
|
|
||
| DropShadowText { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,25 +13,60 @@ Control { | |
| id: root | ||
| focus: true | ||
|
|
||
| // Maximum retry attempts for focus operations when delegate creation is pending | ||
| readonly property int maxFocusRetries: 5 | ||
|
|
||
| required property NotifyModel notifyModel | ||
| property alias viewPanelShown: view.panelShown | ||
| readonly property real viewHeight: view.contentHeight | ||
| readonly property int viewCount: view.count | ||
|
|
||
| signal gotoHeaderFirst() // Signal to cycle Tab back to header first button | ||
| signal gotoHeaderLast() // Signal to cycle Shift+Tab back to header last button | ||
|
|
||
| NotifySetting { | ||
| id: notifySetting | ||
| notifyModel: root.notifyModel | ||
| } | ||
|
|
||
| // Focus notify item at specified index with retry logic for delegate creation | ||
| function focusItemAtIndex(idx) { | ||
| if (idx < 0 || idx >= view.count) return false | ||
| view.currentIndex = idx | ||
| view.positionViewAtIndex(idx, ListView.Contain) | ||
| function tryFocus(retries) { | ||
| let item = view.itemAtIndex(idx) | ||
| if (item && item.enabled) { | ||
| item.forceActiveFocus() | ||
| } else if (retries > 0) { | ||
| Qt.callLater(function() { tryFocus(retries - 1) }) | ||
| } | ||
|
Comment on lines
+36
to
+43
|
||
| } | ||
| Qt.callLater(function() { tryFocus(root.maxFocusRetries) }) | ||
| return true | ||
|
Comment on lines
+32
to
+46
|
||
| } | ||
|
|
||
| // Focus the last notify item for Shift+Tab cycling from header | ||
| function focusLastItem() { | ||
| if (view.count > 0) { | ||
| focusItemAtIndex(view.count - 1) | ||
| } | ||
| } | ||
|
|
||
| contentItem: ListView { | ||
| id: view | ||
| spacing: 10 | ||
| snapMode: ListView.SnapToItem | ||
| // activeFocusOnTab: true | ||
| keyNavigationEnabled: false | ||
| activeFocusOnTab: false | ||
| ScrollBar.vertical: ScrollBar { } | ||
| property int nextIndex: -1 | ||
| property bool panelShown: false | ||
|
|
||
|
|
||
| // Forward signals from delegate to root for Tab cycling | ||
| function gotoHeaderFirst() { root.gotoHeaderFirst() } | ||
| function gotoHeaderLast() { root.gotoHeaderLast() } | ||
|
|
||
| onNextIndexChanged: { | ||
| if (nextIndex >= 0 && count > 0) { | ||
| currentIndex = nextIndex | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting focus to false directly on a control before triggering navigation may not properly clear the focus state. Consider using Qt.callLater to ensure the focus state is cleared after the event is processed, similar to how other navigation code uses Qt.callLater for focus operations.