From cac47746412d9f7e0bd8ce1298f80fae0477692e Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sun, 19 Apr 2026 02:05:30 +0100 Subject: [PATCH] fix(base): stop runaway pagination loop caused by browser scroll anchoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browser overflow-anchor silently bumped scrollTop by one page's worth of pixels every time a new page of rows committed — anchoring on the AddRowButton that sits below paddingBottom. This kept the near-bottom threshold satisfied and re-fired onFetchNextPage indefinitely, even after the user released the scrollbar. Disabling scroll anchoring on the grid scroll container stops the browser from adjusting scrollTop in response to content growth. --- .../src/features/base/components/grid/grid-container.tsx | 7 ------- apps/client/src/features/base/styles/grid.module.css | 1 + 2 files changed, 1 insertion(+), 7 deletions(-) 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 78d45fe5..41e716c0 100644 --- a/apps/client/src/features/base/components/grid/grid-container.tsx +++ b/apps/client/src/features/base/components/grid/grid-container.tsx @@ -60,13 +60,6 @@ export function GridContainer({ onFetchNextPage, }: GridContainerProps) { const scrollRef = useRef(null); - // Records the `rows.length` at which we last triggered a page fetch. - // The trigger effect re-runs on every render (its `virtualItems` dep - // has a new identity each call) and can't rely on `isFetchingNextPage` - // alone: once a page commits, `isFetchingNextPage` flips to false for - // one render, the "near bottom" condition still holds because the - // virtualizer anchors on the old scroll position, and we'd fire again. - // Gating on `rows.length` guarantees at most one fire per new page. const lastTriggeredRowsLenRef = useRef(0); const rows = table.getRowModel().rows; diff --git a/apps/client/src/features/base/styles/grid.module.css b/apps/client/src/features/base/styles/grid.module.css index ffdb99b3..0bd21150 100644 --- a/apps/client/src/features/base/styles/grid.module.css +++ b/apps/client/src/features/base/styles/grid.module.css @@ -1,6 +1,7 @@ .gridWrapper { position: relative; overflow: auto; + overflow-anchor: none; flex: 1; min-height: 0; padding-left: 6px;