Skip to content

Commit 79f087e

Browse files
committed
fix: improve focus management in folder grid view
1. Added activeFocusOnTab: false to prevent unwanted tab focus on SwipeView 2. Implemented onCurrentIndexChanged handler to properly transfer focus to grid view when switching pages 3. Added onActiveFocusChanged handlers to reset currentIndex to 0 when grid views gain focus 4. This ensures consistent focus behavior and prevents focus issues when navigating between pages fix: 改进文件夹网格视图的焦点管理 1. 添加 activeFocusOnTab: false 防止 SwipeView 上出现不需要的标签焦点 2. 实现 onCurrentIndexChanged 处理程序,在切换页面时正确将焦点传递到网格 视图 3. 添加 onActiveFocusChanged 处理程序,在网格视图获得焦点时将 currentIndex 重置为 0 4. 确保一致的焦点行为,防止在页面间导航时出现焦点问题 Pms: BUG-296091
1 parent 1198277 commit 79f087e

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

qml/FolderGridViewPopup.qml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ Popup {
250250
anchors.fill: parent
251251

252252
currentIndex: folderPageIndicator.currentIndex
253+
activeFocusOnTab: false
254+
255+
// 处理页面切换时的焦点传递
256+
onCurrentIndexChanged: {
257+
if (currentItem)
258+
currentItem.resetCurrentIndex()
259+
}
253260

254261
Connections {
255262
target: ItemArrangementProxyModel
@@ -268,9 +275,21 @@ Popup {
268275
id: folderGridViewLoader
269276
objectName: "Folder GridView Loader"
270277

278+
function resetCurrentIndex() {
279+
if (item && item.resetGridFocus)
280+
item.resetGridFocus()
281+
}
282+
271283
sourceComponent: Rectangle {
272284
anchors.fill: parent
273285
color: "transparent"
286+
287+
function resetGridFocus() {
288+
if (gridViewContainerLoader && gridViewContainerLoader.item) {
289+
gridViewContainerLoader.item.currentIndex = 0
290+
gridViewContainerLoader.item.forceActiveFocus()
291+
}
292+
}
274293

275294
MultipageSortFilterProxyModel {
276295
id: folderProxyModel
@@ -320,6 +339,11 @@ Popup {
320339
gridViewClip: false // TODO it maybe a bug for dtk, https://github.com/linuxdeepin/developer-center/issues/8468
321340
activeGridViewFocusOnTab: folderGridViewLoader.SwipeView.isCurrentItem
322341
itemMove: parent.itemMove
342+
onActiveFocusChanged: {
343+
if (activeFocus) {
344+
currentIndex = 0
345+
}
346+
}
323347
delegate: DelegateDropArea {
324348
width: folderGridViewContainer.cellWidth
325349
height: folderGridViewContainer.cellHeight
@@ -343,6 +367,12 @@ Popup {
343367
gridViewClip: false
344368
activeGridViewFocusOnTab: folderGridViewLoader.SwipeView.isCurrentItem
345369
itemMove: parent.itemMove
370+
371+
onActiveFocusChanged: {
372+
if (activeFocus) {
373+
currentIndex = 0
374+
}
375+
}
346376
delegate: DelegateDropArea {
347377
width: folderGridViewContainer.cellWidth
348378
height: folderGridViewContainer.cellHeight

0 commit comments

Comments
 (0)