Skip to content

Commit

Permalink
fix: highlight not visible when focus in
Browse files Browse the repository at this point in the history
Always scroll to the highlight when focus in.

Log: fix highlight not visible when focus in
Issue: linuxdeepin/developer-center#6397
  • Loading branch information
asterwyx committed Jan 5, 2024
1 parent 8fb6213 commit 563d472
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions qml/AppListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Item {
// the scroll might stopped before the highlight item scroll to the expected place.
// Thus we use a timer to set back these values with a delay.
listView.highlightMoveDuration = 150
listView.highlightRangeMode = GridView.NoHighlightRange
listView.highlightRangeMode = ListView.NoHighlightRange
}
}

Expand All @@ -34,14 +34,20 @@ Item {
if (character === transliterated1st) {
// we use the highlight move to scroll to item
listView.highlightMoveDuration = 0
listView.highlightRangeMode = GridView.ApplyRange
listView.highlightRangeMode = ListView.StrictlyEnforceRange
listView.currentIndex = i
postScrollDeferTimer.restart()
break
}
}
}

function scrollToHighlight() {
listView.highlightMoveDuration = 0
listView.highlightRangeMode = ListView.StrictlyEnforceRange
postScrollDeferTimer.restart()
}

Component {
id: sectionHeading
ToolButton {
Expand Down Expand Up @@ -86,6 +92,12 @@ Item {
// displayMarginBeginning: -45
clip: true
focus: true
onFocusChanged: {
if (focus) {
// When focus in, we always scroll to the highlight
scrollToHighlight()
}
}

section.property: CategorizedSortProxyModel.sortRoleName // "transliterated" // "category"
section.criteria: section.property === "transliterated" ? ViewSection.FirstCharacter : ViewSection.FullString
Expand Down

0 comments on commit 563d472

Please sign in to comment.