Skip to content

Commit 33af38e

Browse files
committed
feat: set focus to first expanded notification item
1. Add logic to automatically set ListView currentIndex to the first notification item when expanding an app group 2. This improves keyboard navigation by moving focus to the newly expanded content 3. Calculate the correct index by adding 1 to the expanded app index 4. Only apply the focus change when the root view is available feat: 设置焦点到新展开的首条通知项 1. 添加逻辑在展开应用组时自动将 ListView 当前索引设置到第一条通知项 2. 通过将焦点移动到新展开的内容来改进键盘导航体验 3. 通过展开应用索引加1计算正确的索引位置 4. 仅在根视图可用时应用焦点更改 5.修复了删除后,焦点给到下一项 PMS: BUG-284987
1 parent adde632 commit 33af38e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

panels/notification/center/NotifyViewDelegate.qml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,21 @@ DelegateChooser {
102102
}
103103
onRemove: function () {
104104
console.log("remove normal", model.id)
105+
let removeIndex = index
105106
notifyModel.remove(model.id)
107+
let nextIndex = Math.min(removeIndex, root.view.count - 1)
108+
if (nextIndex >= 0 && root.view.count > 0) {
109+
root.view.currentIndex = nextIndex
110+
}
106111
}
107112
onDismiss: function () {
108113
console.log("dismiss normal", model.id)
114+
let dismissIndex = index
109115
notifyModel.remove(model.id)
116+
let nextIndex = Math.min(dismissIndex, root.view.count - 1)
117+
if (nextIndex >= 0 && root.view.count > 0) {
118+
root.view.currentIndex = nextIndex
119+
}
110120
}
111121
onActionInvoked: function (actionId) {
112122
console.log("action normal", model.id, actionId)
@@ -163,7 +173,13 @@ DelegateChooser {
163173
onExpand: function ()
164174
{
165175
console.log("expand")
166-
notifyModel.expandApp(model.index)
176+
let expandIndex = model.index
177+
notifyModel.expandApp(expandIndex)
178+
// 设置ListView的currentIndex到新展开的首条通知项 (将焦点设置到新展开的通知的第一项)
179+
if (root.view) {
180+
let firstExpandedIndex = expandIndex + 1
181+
root.view.currentIndex = firstExpandedIndex
182+
}
167183
}
168184
onSetting: function (pos) {
169185
let tmp = mapToItem(root.view, pos)

0 commit comments

Comments
 (0)