From e25899b3ee80dcad213739ed77881f09e366cb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Gla=CC=88ser?= Date: Wed, 30 Sep 2026 10:37:38 +0200 Subject: [PATCH] Delay scroll restoration after card refresh --- public/scripts/shared-editable-action-card.js | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/public/scripts/shared-editable-action-card.js b/public/scripts/shared-editable-action-card.js index ebf791b..57428d1 100644 --- a/public/scripts/shared-editable-action-card.js +++ b/public/scripts/shared-editable-action-card.js @@ -28,25 +28,30 @@ container, top: container.scrollTop, left: container.scrollLeft, - scheduled: false, + timer: null, }); }; const restoreScrollPosition = (root) => { const state = scrollRestoreStates.get(root); - if (!state || state.scheduled) { + if (!state) { return; } - state.scheduled = true; - requestAnimationFrame(() => { + if (state.timer) { + window.clearTimeout(state.timer); + } + + state.timer = window.setTimeout(() => { requestAnimationFrame(() => { - if (state.container?.isConnected) { - state.container.scrollTo({ top: state.top, left: state.left, behavior: 'auto' }); - } - scrollRestoreStates.delete(root); + requestAnimationFrame(() => { + if (state.container?.isConnected) { + state.container.scrollTo({ top: state.top, left: state.left, behavior: 'auto' }); + } + scrollRestoreStates.delete(root); + }); }); - }); + }, 100); }; const getDirectDeleteElement = (card, selector) => Array.from(card?.children || [])