Skip to content

Commit 28d92e3

Browse files
committed
fix: prevent bumpPage from firing after filter changes
1 parent 26af872 commit 28d92e3

5 files changed

Lines changed: 14 additions & 11 deletions

File tree

884 Bytes
Loading
Loading
Loading

packages/pluggableWidgets/datagrid-web/src/model/hooks/useInfiniteControl.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@ export function useInfiniteControl(): [trackBodyScrolling: ((e: any) => void) |
4646
if (!isVisible) {
4747
return;
4848
}
49+
50+
const wasLocked = gridSizeStore.gridBodyHeight !== undefined;
4951
gridSizeStore.lockGridBodyHeight();
52+
const justLocked = !wasLocked && gridSizeStore.gridBodyHeight !== undefined;
5053

51-
const gridBody = gridSizeStore.gridBodyRef.current;
52-
if (gridBody && gridSizeStore.hasMoreItems && gridBody.scrollHeight <= gridBody.clientHeight) {
53-
gridSizeStore.bumpPage();
54+
if (justLocked) {
55+
const gridBody = gridSizeStore.gridBodyRef.current;
56+
if (gridBody && gridSizeStore.hasMoreItems && gridBody.scrollHeight <= gridBody.clientHeight) {
57+
gridSizeStore.bumpPage();
58+
}
5459
}
5560
}, 100);
5661
return () => clearTimeout(timer);

packages/pluggableWidgets/datagrid-web/src/model/stores/GridSize.store.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,17 @@ export class GridSizeStore {
122122
const viewportHeight = this.computeBodyViewport();
123123

124124
// Don't lock height before the grid body has rendered content.
125-
// viewportHeight is 0 when cells have no layout yet, which would
125+
// clientHeight is 0 when the element has no layout yet, which would
126126
// produce a negative height and break scrolling.
127127
if (viewportHeight <= 0) {
128128
return;
129129
}
130130

131-
// Compare scrollHeight and clientHeight from the same element to correctly
132-
// detect whether content already overflows a fixed-height container.
133-
// If it does, do not subtract the pre-fetch offset — that would hide the
134-
// last rows and trigger the next page too early. Only subtract when the
135-
// grid does not yet overflow (auto-height grid) to create a small synthetic
136-
// overflow that makes the body scrollable.
137-
const overflows = gridBody.scrollHeight > gridBody.clientHeight;
131+
// If content already overflows the container (fixed-height grid), do not subtract the
132+
// pre-fetch offset — that would hide the last rows and trigger the next page too early.
133+
// Only subtract the offset when the grid does not yet overflow (auto-height grid) so
134+
// that we create a small synthetic overflow that makes the body scrollable.
135+
const overflows = gridBody.scrollHeight > viewportHeight;
138136
this.gridBodyHeight = viewportHeight - (overflows ? 0 : VIRTUAL_SCROLLING_OFFSET);
139137
this.lockedAtPageSize = currentPageSize;
140138
}

0 commit comments

Comments
 (0)