From f22fea5f2245e0e4e83f07b92cea3f637c6430a3 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 25 Jan 2022 19:05:54 +0100 Subject: [PATCH] Scroll back to top when contents of table change Contributes to issue CURA-8686. --- plugins/DigitalLibrary/resources/qml/Table.qml | 11 ++++++++++- resources/qml/TableView.qml | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/plugins/DigitalLibrary/resources/qml/Table.qml b/plugins/DigitalLibrary/resources/qml/Table.qml index 6eec4d4090..b6162e9135 100644 --- a/plugins/DigitalLibrary/resources/qml/Table.qml +++ b/plugins/DigitalLibrary/resources/qml/Table.qml @@ -113,7 +113,7 @@ Item { // Vertical ScrollBar, styled similarly to the scrollBar in the settings panel id: verticalScrollBar - visible: flickableView.contentHeight > flickableView.height + visible: tableView.contentHeight > tableView.height background: Rectangle { @@ -169,5 +169,14 @@ Item } } } + + Connections + { + target: model + function onRowCountChanged() + { + tableView.contentY = 0; //When the number of rows is reduced, make sure to scroll back to the start. + } + } } } \ No newline at end of file diff --git a/resources/qml/TableView.qml b/resources/qml/TableView.qml index cb4ca1fe37..079e25d717 100644 --- a/resources/qml/TableView.qml +++ b/resources/qml/TableView.qml @@ -147,5 +147,14 @@ Item } } } + + Connections + { + target: model + function onRowCountChanged() + { + tableView.contentY = 0; //When the number of rows is reduced, make sure to scroll back to the start. + } + } } } \ No newline at end of file