From 86809fc0dc6278485974b99f21bb2a3ebb47921c Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Tue, 28 Apr 2026 10:39:20 +0100 Subject: [PATCH] fix scroll bug --- .../base/components/grid/grid-container.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/client/src/features/base/components/grid/grid-container.tsx b/apps/client/src/features/base/components/grid/grid-container.tsx index 65c7deaf1..f9aa001db 100644 --- a/apps/client/src/features/base/components/grid/grid-container.tsx +++ b/apps/client/src/features/base/components/grid/grid-container.tsx @@ -182,6 +182,19 @@ export function GridContainer({ overscan: OVERSCAN, scrollMargin, ...windowScrollOptions, + // virtual-core bug: when the scroll element first attaches in + // _willUpdate, it calls _scrollToOffset(getScrollOffset()). With + // no initialOffset provided, getScrollOffset() returns undefined, + // and windowScroll/elementScroll computes `undefined + 0 = NaN` + // for the scroll target. Browsers coerce that to 0, so + // scrollY/scrollTop snaps to 0 the moment a fresh BaseTable + // mounts mid-page — manifests as "page jumps to top of editor" + // when an inline-embed lands. Seed initialOffset to the current + // scroll position so the first _scrollToOffset is a no-op. + initialOffset: isWindowScroll + ? () => window.scrollY + : () => + scrollElement instanceof HTMLElement ? scrollElement.scrollTop : 0, }); const virtualItems = virtualizer.getVirtualItems();