fix(ui): preserve group editor scroll position when toggling tags

This commit is contained in:
Will Miao
2026-08-24 08:17:47 +08:00
parent 1a93b0eca2
commit 90be5799e4
+8
View File
@@ -439,6 +439,12 @@ function renderGroupEditor(widget, tagData, index) {
return; return;
} }
// Preserve the scroll position across re-renders: toggling a child tag
// rebuilds the whole panel, and a fresh panel would otherwise jump back
// to the top.
const previousScrollTop = state.panelEl ? state.panelEl.scrollTop : 0;
const previousScrollLeft = state.panelEl ? state.panelEl.scrollLeft : 0;
if (state.panelEl) { if (state.panelEl) {
state.panelEl.remove(); state.panelEl.remove();
} }
@@ -551,6 +557,8 @@ function renderGroupEditor(widget, tagData, index) {
state.lastAnchorRect = getRectSnapshot(state.anchorEl); state.lastAnchorRect = getRectSnapshot(state.anchorEl);
attachGroupEditorCloseHandlers(widget); attachGroupEditorCloseHandlers(widget);
positionGroupEditor(widget); positionGroupEditor(widget);
panel.scrollTop = previousScrollTop;
panel.scrollLeft = previousScrollLeft;
startGroupEditorTracking(widget); startGroupEditorTracking(widget);
} }