diff options
| -rw-r--r-- | src/controls/TableView.qml | 2 | ||||
| -rw-r--r-- | tests/auto/controls/data/tst_tableview.qml | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/controls/TableView.qml b/src/controls/TableView.qml index 736ac6e39..595c13cab 100644 --- a/src/controls/TableView.qml +++ b/src/controls/TableView.qml @@ -696,7 +696,7 @@ ScrollView { model: root.model function keySelect(shiftPressed, row) { - if (row < 0 || row === rowCount - 1) + if (row < 0 || row > rowCount - 1) return if (shiftPressed && (selectionMode >= SelectionMode.ExtendedSelection)) { selection.__ranges = new Array() diff --git a/tests/auto/controls/data/tst_tableview.qml b/tests/auto/controls/data/tst_tableview.qml index 7f1b48dca..192e29b5b 100644 --- a/tests/auto/controls/data/tst_tableview.qml +++ b/tests/auto/controls/data/tst_tableview.qml @@ -148,6 +148,34 @@ TestCase { verify(table.selection.contains(4)) verify(table.selection.contains(5)) verify(table.selection.count === 2) + + // Navigate to end using arrow keys + table.selectionMode = SelectionMode.SingleSelection + table.model = 3 + table.currentRow = -1 + keyClick(Qt.Key_Down); + verify(table.currentRow === 0) + verify(rangeTest([[0,0]], table)) + verify(table.selection.contains(0)) + keyClick(Qt.Key_Down); + verify(table.currentRow === 1) + verify(table.selection.contains(1)) + keyClick(Qt.Key_Down); + verify(table.currentRow === 2) + verify(table.selection.contains(2)) + keyClick(Qt.Key_Down); + verify(table.currentRow === 2) + verify(table.selection.contains(2)) + keyClick(Qt.Key_Up); + verify(table.currentRow === 1) + verify(table.selection.contains(1)) + keyClick(Qt.Key_Up); + verify(table.currentRow === 0) + verify(table.selection.contains(0)) + keyClick(Qt.Key_Up); + verify(table.currentRow === 0) + verify(table.selection.contains(0)) + table.destroy() } |
