Skip to content

Commit 673af4d

Browse files
committed
fix: move virtual scrolling logic to GridSizeStore for convenience
1 parent 8ee3112 commit 673af4d

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

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

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,7 @@ export function useInfiniteControl(): [trackTableScrolling: ((e: any) => void) |
4242
);
4343

4444
useEffect(() => {
45-
const timer = setTimeout(() => {
46-
if (!isVisible) {
47-
return;
48-
}
49-
const wasLocked = gridSizeStore.gridContainerHeight !== undefined;
50-
gridSizeStore.lockGridContainerHeight();
51-
const justLocked = !wasLocked && gridSizeStore.gridContainerHeight !== undefined;
52-
53-
if (justLocked) {
54-
const gridBody = gridSizeStore.gridBodyRef.current;
55-
if (gridBody && gridSizeStore.hasMoreItems && gridBody.scrollHeight <= gridBody.clientHeight) {
56-
gridSizeStore.bumpPage();
57-
}
58-
}
59-
}, 100);
45+
const timer = setTimeout(() => isVisible && gridSizeStore.lockGridContainerHeight(), 100);
6046
return () => clearTimeout(timer);
6147
});
6248

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,10 @@ export class GridSizeStore {
112112
const overflows = gridContainer.scrollHeight > fullHeight;
113113
this.gridContainerHeight = fullHeight - (overflows ? 0 : VIRTUAL_SCROLLING_OFFSET);
114114
this.lockedAtPageSize = currentPageSize;
115+
116+
const gridBody = this.gridBodyRef.current;
117+
if (this.hasMoreItems && gridBody && gridBody.scrollHeight <= gridBody.clientHeight) {
118+
this.bumpPage();
119+
}
115120
}
116121
}

0 commit comments

Comments
 (0)