fix scroll position reset when toggling group collapse
This commit is contained in:
parent
69dff5a263
commit
7d5854e340
1 changed files with 12 additions and 2 deletions
|
|
@ -70,15 +70,18 @@ M.HoverPanel {
|
||||||
// Collapsed groups set — reassign to trigger reactivity
|
// Collapsed groups set — reassign to trigger reactivity
|
||||||
property var _collapsedGroups: ({})
|
property var _collapsedGroups: ({})
|
||||||
|
|
||||||
|
property real _savedScrollY: 0
|
||||||
|
property bool _restoringScroll: false
|
||||||
|
|
||||||
function _toggleCollapse(appName) {
|
function _toggleCollapse(appName) {
|
||||||
const savedY = notifList.contentY;
|
_savedScrollY = notifList.contentY;
|
||||||
|
_restoringScroll = true;
|
||||||
const next = Object.assign({}, _collapsedGroups);
|
const next = Object.assign({}, _collapsedGroups);
|
||||||
if (next[appName])
|
if (next[appName])
|
||||||
delete next[appName];
|
delete next[appName];
|
||||||
else
|
else
|
||||||
next[appName] = true;
|
next[appName] = true;
|
||||||
_collapsedGroups = next;
|
_collapsedGroups = next;
|
||||||
Qt.callLater(() => notifList.contentY = savedY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Group notifications by appName, sorted by max urgency desc then most recent time desc
|
// Group notifications by appName, sorted by max urgency desc then most recent time desc
|
||||||
|
|
@ -228,6 +231,13 @@ M.HoverPanel {
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
model: menuWindow._flatModel
|
model: menuWindow._flatModel
|
||||||
|
|
||||||
|
onContentHeightChanged: {
|
||||||
|
if (menuWindow._restoringScroll) {
|
||||||
|
contentY = Math.min(menuWindow._savedScrollY, Math.max(0, contentHeight - height));
|
||||||
|
menuWindow._restoringScroll = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: notifDelegate
|
id: notifDelegate
|
||||||
required property var modelData
|
required property var modelData
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue