From 331c269f112286c5d2f7f8f4a492ac117ad0317c Mon Sep 17 00:00:00 2001 From: Yixue Wang Date: Tue, 9 Jan 2024 14:25:03 +0800 Subject: [PATCH] fix: abnormal view of applistview * Cause highlight move forcely position highlight item at the top, We revert to ApplyRange. * Every time focus in, we set the currentIndex to 0, and every time focus out, we clear currentItem. Log: fix abnormal view of applistview --- qml/AppListView.qml | 5 ++++- qml/GridViewContainer.qml | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qml/AppListView.qml b/qml/AppListView.qml index c8bee229..62a37b9b 100644 --- a/qml/AppListView.qml +++ b/qml/AppListView.qml @@ -38,7 +38,7 @@ Item { if (character === transliterated1st) { // we use the highlight move to scroll to item listView.highlightMoveDuration = 0 - listView.highlightRangeMode = ListView.StrictlyEnforceRange + listView.highlightRangeMode = ListView.ApplyRange listView.currentIndex = i postScrollDeferTimer.restart() break @@ -94,8 +94,11 @@ Item { if (activeFocus) { // When focus in, we always scroll to the highlight listView.highlightMoveDuration = 0 + listView.currentIndex = 0 listView.highlightRangeMode = ListView.StrictlyEnforceRange postScrollDeferTimer.restart() + } else { + listView.currentIndex = -1 } } diff --git a/qml/GridViewContainer.qml b/qml/GridViewContainer.qml index 7df89254..b79fef47 100644 --- a/qml/GridViewContainer.qml +++ b/qml/GridViewContainer.qml @@ -77,8 +77,11 @@ FocusScope { onActiveFocusChanged: { if (activeFocus) { gridView.highlightMoveDuration = 0 + gridView.currentIndex = 0 gridView.highlightRangeMode = GridView.StrictlyEnforceRange postScrollDeferTimer.restart() + } else { + gridView.currentIndex = -1 } } cellHeight: item.cellSize