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 || [])