Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fire load more slightly before reaching the bottom of the page (#47115)

Joshen Lime9a976aa7486
diff --git a/apps/studio/components/ui/DataTable/DataTableInfinite.tsx b/apps/studio/components/ui/DataTable/DataTableInfinite.tsx
index c7a774c0e7c..8ca89276707 100644
--- a/apps/studio/components/ui/DataTable/DataTableInfinite.tsx
+++ b/apps/studio/components/ui/DataTable/DataTableInfinite.tsx
@@ -54,15 +54,17 @@ export function DataTableInfinite<TData, TValue, TMeta>({
const onScroll = useCallback(
(e: UIEvent<HTMLElement>) => {
+ // Trigger fetching slightly before reaching the very bottom for a smoother experience
+ const BOTTOM_BUFFER_PX = 300
const onPageBottom =
Math.ceil(e.currentTarget.scrollTop + e.currentTarget.clientHeight) >=
- e.currentTarget.scrollHeight
+ e.currentTarget.scrollHeight - BOTTOM_BUFFER_PX
- if (onPageBottom && !isFetching && totalRows > totalRowsFetched) {
+ if (onPageBottom && !isFetching && hasNextPage) {
fetchNextPage()
}
},
- [fetchNextPage, isFetching, totalRows, totalRowsFetched]
+ [fetchNextPage, isFetching, hasNextPage]
)
useShortcut(