Skip to content

Commit 67e8d43

Browse files
committed
fix: make loadMoreOffset dynamic
1 parent b3cdc3b commit 67e8d43

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/raystack/components/data-table/components/virtualized-content.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export function VirtualizedContent({
163163
rowHeight = 40,
164164
groupHeaderHeight,
165165
overscan = 5,
166+
loadMoreOffset = 100,
166167
emptyState,
167168
zeroState,
168169
classNames = {}
@@ -191,10 +192,10 @@ export function VirtualizedContent({
191192
if (!scrollContainerRef.current || isLoading) return;
192193
const { scrollTop, scrollHeight, clientHeight } =
193194
scrollContainerRef.current;
194-
if (scrollHeight - scrollTop - clientHeight < 100) {
195+
if (scrollHeight - scrollTop - clientHeight < loadMoreOffset) {
195196
loadMoreData();
196197
}
197-
}, [isLoading, loadMoreData]);
198+
}, [isLoading, loadMoreData, loadMoreOffset]);
198199

199200
const hasData = rows?.length > 0 || isLoading;
200201

packages/raystack/components/data-table/data-table.types.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,16 @@ export type DataTableContentBaseProps = {
128128
export type DataTableContentProps = DataTableContentBaseProps;
129129

130130
export type VirtualizedContentProps = DataTableContentBaseProps & {
131+
/** Height of the scroll container. */
131132
height?: number | string;
133+
/** Height of each row in pixels. */
132134
rowHeight?: number;
135+
/** Height of group header rows in pixels. Falls back to rowHeight if not set. */
133136
groupHeaderHeight?: number;
137+
/** Number of rows to render outside visible area. */
134138
overscan?: number;
139+
/** Distance in pixels from bottom to trigger load more. */
140+
loadMoreOffset?: number;
135141
};
136142

137143
export type TableQueryUpdateFn = (query: InternalQuery) => InternalQuery;

0 commit comments

Comments
 (0)