-
Notifications
You must be signed in to change notification settings - Fork 55
fix: improve focus handling after expand/collapse in NotifyView #1385
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
Conversation
Reviewer's GuideImplements a more reliable focus restoration mechanism in NotifyView after expand/collapse by introducing a retry-based timer that attempts to focus the intended list item once it becomes available, and wiring delegate expand/collapse handlers to use this new helper instead of manually tweaking nextIndex. Sequence diagram for focus handling after expand in NotifyViewsequenceDiagram
actor User
participant NotifyViewDelegate
participant NotifyModel
participant View as NotifyViewListView
participant Timer as ExpandFocusTimer
participant Item as ListItem
User->>NotifyViewDelegate: activate expand on notification
NotifyViewDelegate->>NotifyModel: expandApp(expandIndex)
NotifyViewDelegate->>View: requestFocusOnExpand(expandIndex_plus_1)
Note over View: requestFocusOnExpand
View->>View: pendingFocusIndex = idx
View->>View: currentIndex = idx
View->>View: positionViewAtIndex(idx, Contain)
View->>Timer: set retries = 15
View->>Timer: start()
loop until focus set or retries exhausted
Timer->>View: onTriggered
View->>View: item = itemAtIndex(pendingFocusIndex)
alt item exists and enabled
View->>Item: forceActiveFocus()
View->>View: pendingFocusIndex = -1
Timer->>Timer: stop()
else retries <= 0
View->>View: pendingFocusIndex = -1
Timer->>Timer: stop()
else
Timer->>Timer: retries--
end
end
Sequence diagram for focus handling after collapse in NotifyViewsequenceDiagram
actor User
participant NotifyViewDelegate
participant NotifyModel
participant View as NotifyViewListView
participant Timer as ExpandFocusTimer
participant Item as ListItem
User->>NotifyViewDelegate: activate collapse on grouped notification
NotifyViewDelegate->>NotifyViewDelegate: collapseIndex = index
NotifyViewDelegate->>NotifyModel: collapseApp(index)
NotifyViewDelegate->>View: requestFocusOnExpand(collapseIndex)
Note over View: requestFocusOnExpand
View->>View: pendingFocusIndex = idx
View->>View: currentIndex = idx
View->>View: positionViewAtIndex(idx, Contain)
View->>Timer: set retries = 15
View->>Timer: start()
loop until focus set or retries exhausted
Timer->>View: onTriggered
View->>View: item = itemAtIndex(pendingFocusIndex)
alt item exists and enabled
View->>Item: forceActiveFocus()
View->>View: pendingFocusIndex = -1
Timer->>Timer: stop()
else retries <= 0
View->>View: pendingFocusIndex = -1
Timer->>Timer: stop()
else
Timer->>Timer: retries--
end
end
Flow diagram for retry-based focus timer in NotifyViewflowchart TD
A[start expand or collapse handler]
A-->B["call requestFocusOnExpand(idx)"]
B-->C[set pendingFocusIndex = idx]
C-->D[set currentIndex = idx]
D-->E["positionViewAtIndex(idx, Contain)"]
E-->F[set expandFocusTimer.retries = 15]
F-->G[start expandFocusTimer]
subgraph TimerLoop[ExpandFocusTimer onTriggered]
G-->H["retrieve item = view.itemAtIndex(pendingFocusIndex)"]
H-->I{"item exists and item.enabled?"}
I-- Yes -->J["call item.forceActiveFocus()"]
J-->K[set pendingFocusIndex = -1]
K-->L[stop timer]
I-- No -->M{retries <= 0?}
M-- Yes -->N[set pendingFocusIndex = -1]
N-->L
M-- No -->O[retries--]
O-->H
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Added retry timer mechanism to reliably set focus after expand/collapse operations. Log: improve focus handling after expand/collapse in NotifyView pms: BUG-339891
deepin pr auto review我来分析这段代码的修改:
建议改进:
总体来说,这是一个很好的改进,提高了通知中心展开/折叠操作的可靠性和用户体验。代码结构清晰,考虑了各种边界情况,是一个可靠的实现。 |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Added retry timer mechanism to reliably set focus after expand/collapse operations.
Log: improve focus handling after expand/collapse in NotifyView
pms: BUG-339891
Summary by Sourcery
Bug Fixes: