Skip to content

Commit 4a4b358

Browse files
committed
fix: Handle exceptions when hovering over up/down arrows
log: Modify arrow scrolling logic to adjust only contentY (scroll by step size in pixels), completely bypassing currentIndex. Also add single-step scrolling when clicking arrows. pms: bug-335545
1 parent b589d3c commit 4a4b358

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

qt6/src/qml/ArrowListView.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ FocusScope {
2727
Layout.fillWidth: true
2828
Layout.preferredHeight: height
2929
view: itemsView
30+
stepSize: control.itemHeight
3031
direction: P.ArrowListViewButton.UpButton
3132
}
3233

@@ -82,6 +83,7 @@ FocusScope {
8283
Layout.fillWidth: true
8384
Layout.preferredHeight: height
8485
view: itemsView
86+
stepSize: control.itemHeight
8587
direction: P.ArrowListViewButton.DownButton
8688
}
8789
}

qt6/src/qml/private/ArrowListViewButton.qml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Loader {
1414

1515
required property Item view
1616
property int direction
17+
property int stepSize: DS.Style.arrowListView.itemHeight
1718
active: view.interactive
1819

1920
sourceComponent: ActionButton {
@@ -26,17 +27,21 @@ Loader {
2627
icon.width: DS.Style.arrowListView.stepButtonIconSize.width
2728
icon.height: DS.Style.arrowListView.stepButtonIconSize.height
2829

29-
// Unified scroll operation function
3030
function performScroll() {
31-
direction === ArrowListViewButton.UpButton ? view.decrementCurrentIndex()
32-
: view.incrementCurrentIndex()
31+
if (!view)
32+
return
33+
var maxY = Math.max(0, view.contentHeight - view.height)
34+
if (maxY <= 0)
35+
return
36+
var step = Math.max(1, stepSize)
37+
var nextY = direction === ArrowListViewButton.UpButton ? (view.contentY - step)
38+
: (view.contentY + step)
39+
view.contentY = Math.max(0, Math.min(maxY, nextY))
3340
}
3441

35-
// Auto-scroll control properties using state machine approach
3642
property bool shouldAutoScroll: hovered && enabled
3743
property bool delayCompleted: false
3844

39-
// Timer for initial delay before starting hover scroll
4045
Timer {
4146
id: initialDelayTimer
4247
interval: 300
@@ -45,20 +50,19 @@ Loader {
4550
onTriggered: delayCompleted = true
4651
}
4752

48-
// Timer for continuous hover scrolling
4953
Timer {
5054
id: hoverScrollTimer
5155
interval: 100
5256
repeat: true
5357
running: shouldAutoScroll && delayCompleted
5458
onTriggered: performScroll()
5559
}
56-
57-
// Reset state when auto-scroll should stop
60+
5861
onShouldAutoScrollChanged: {
59-
if (!shouldAutoScroll) {
62+
if (!shouldAutoScroll)
6063
delayCompleted = false
61-
}
6264
}
65+
66+
onClicked: performScroll()
6367
}
6468
}

0 commit comments

Comments
 (0)