mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix(base): stop runaway pagination loop caused by browser scroll anchoring
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.
This commit is contained in:
@@ -60,13 +60,6 @@ export function GridContainer({
|
|||||||
onFetchNextPage,
|
onFetchNextPage,
|
||||||
}: GridContainerProps) {
|
}: GridContainerProps) {
|
||||||
const scrollRef = useRef<HTMLDivElement>(null);
|
const scrollRef = useRef<HTMLDivElement>(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 lastTriggeredRowsLenRef = useRef(0);
|
||||||
const rows = table.getRowModel().rows;
|
const rows = table.getRowModel().rows;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
.gridWrapper {
|
.gridWrapper {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
overflow-anchor: none;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
|
|||||||
Reference in New Issue
Block a user