From 3e7e817176a09877124e76b42c351db91ecaba95 Mon Sep 17 00:00:00 2001 From: Armin Mehinovic Date: Fri, 2 Aug 2024 19:39:05 +0200 Subject: [PATCH] Loading overlay for the initial load only --- .../src/hooks/features/dataSource/useGridDataSource.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts b/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts index 17e7b7d35a1c..97386a30820a 100644 --- a/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts +++ b/packages/x-data-grid-pro/src/hooks/features/dataSource/useGridDataSource.ts @@ -112,8 +112,10 @@ export const useGridDataSource = ( return; } + // with lazy loading, only the initial load should show the loading overlay + const useLoadingIndicator = !isLazyLoaded || apiRef.current.getRowsCount() === 0; const isLoading = gridRowsLoadingSelector(apiRef); - if (!isLoading) { + if (!isLoading && useLoadingIndicator) { apiRef.current.setLoading(true); } @@ -147,7 +149,7 @@ export const useGridDataSource = ( const fetchRowBatch = React.useCallback( (fetchParams: GridGetRowsParams) => { - if (isLazyLoaded && fetchParams.start && fetchParams.end) { + if (isLazyLoaded) { rowFetchSlice.current = { start: Number(fetchParams.start), end: fetchParams.end }; } return fetchRows();