fix scroll position reset when toggling group collapse

This commit is contained in:
Damocles 2026-04-17 11:48:05 +02:00
parent 69dff5a263
commit 7d5854e340

View file

@ -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