Skip to content

Commit c8bc0c7

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 objectName to gridViewContainerLoader for reliable identification in focus logic 4. Added onActiveFocusChanged handlers to reset currentIndex to 0 when grid views gain focus 5. This ensures consistent focus behavior and prevents focus issues when navigating between pages fix: 改进文件夹网格视图的焦点管理 1. 添加 activeFocusOnTab: false 防止 SwipeView 上出现不需要的标签焦点 2. 实现 onCurrentIndexChanged 处理程序,在切换页面时正确将焦点传递到网格 视图 3. 为 gridViewContainerLoader 添加 objectName 以便在焦点逻辑中可靠识别 4. 添加 onActiveFocusChanged 处理程序,在网格视图获得焦点时将 currentIndex 重置为 0 5. 确保一致的焦点行为,防止在页面间导航时出现焦点问题 Pms: BUG-296091
1 parent 1176770 commit c8bc0c7

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,24 @@ Popup {
250250
anchors.fill: parent
251251

252252
currentIndex: folderPageIndicator.currentIndex
253+
activeFocusOnTab: false
254+
255+
// 处理页面切换时的焦点传递
256+
onCurrentIndexChanged: {
257+
if (currentItem && currentItem.item) {
258+
var rectangle = currentItem.item
259+
if (rectangle && rectangle.children) {
260+
for (var i = 0; i < rectangle.children.length; i++) {
261+
var child = rectangle.children[i]
262+
if (child && child.objectName === "gridViewContainerLoader" && child.item) {
263+
child.item.currentIndex = 0
264+
child.item.forceActiveFocus()
265+
break
266+
}
267+
}
268+
}
269+
}
270+
}
253271

254272
Connections {
255273
target: ItemArrangementProxyModel
@@ -292,6 +310,7 @@ Popup {
292310
//gridViewContainer
293311
Loader {
294312
id: gridViewContainerLoader
313+
objectName: "gridViewContainerLoader"
295314
anchors.fill: parent
296315
sourceComponent: isWindowedMode ? listViewGridViewContainer : fullScreenGridViewContainer
297316

@@ -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)