Skip to content

Commit 38ec4ca

Browse files
committed
fix: show loading spinner when fetching
1 parent 5bf39ee commit 38ec4ca

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/components/data_library/LibraryDataGrid.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,23 @@ export const LibraryDataGrid: React.FC<LibraryDataGridProps> = ({
111111
return true
112112
}
113113

114+
// Show loading state when data is empty and loading
115+
if (isEmpty(data) && loading) {
116+
return (
117+
<Box
118+
sx={{
119+
display: 'flex',
120+
justifyContent: 'center',
121+
alignItems: 'center',
122+
height: '50vh',
123+
}}
124+
>
125+
<CircularProgress />
126+
</Box>
127+
)
128+
}
129+
130+
// Show empty state only when not loading and no data
114131
if (isEmpty(data) && !loading) {
115132
return (
116133
<Box

src/pages/DataLibrary.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const DataLibrary: React.FC = () => {
7878
}
7979

8080
// Fetch data based on current state
81-
const { data, isLoading, error } = useLibraryData(
81+
const { data, isLoading, isFetching, error } = useLibraryData(
8282
libraryConfig,
8383
urlState.tab,
8484
urlState.filters,
@@ -227,7 +227,7 @@ export const DataLibrary: React.FC = () => {
227227
<LibraryDataGrid
228228
assetType={urlState.tab}
229229
data={data?.items || []}
230-
loading={isLoading}
230+
loading={isFetching}
231231
total={data?.total || 0}
232232
paginationModel={{
233233
page: urlState.page,

0 commit comments

Comments
 (0)