Only show full-table spinner on truly initial load
Track whether the table has ever received data. A filter change that empties the client-side entity list (e.g. filtering by an owner with no matches) should not trigger the full-table loading spinner — the table should show "No records" or stale rows with the title spinner, not flash a large spinner. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -43,7 +43,7 @@ import Edit from '@material-ui/icons/Edit';
|
||||
import OpenInNew from '@material-ui/icons/OpenInNew';
|
||||
import { capitalize, sortBy } from 'lodash';
|
||||
import pluralize from 'pluralize';
|
||||
import { ReactNode, useMemo } from 'react';
|
||||
import { ReactNode, useMemo, useRef } from 'react';
|
||||
import { columnFactories } from './columns';
|
||||
import { CatalogTableColumnsFunc, CatalogTableRow } from './types';
|
||||
import { OffsetPaginatedCatalogTable } from './OffsetPaginatedCatalogTable';
|
||||
@@ -114,11 +114,14 @@ export const CatalogTable = (props: CatalogTableProps) => {
|
||||
paginationMode,
|
||||
} = entityListContext;
|
||||
|
||||
// Only show the full-table loading spinner on the very first load when
|
||||
// there's no data yet. During subsequent fetches (filter changes, page
|
||||
// navigation) we keep stale rows visible so the user sees content
|
||||
// immediately — a small spinner next to the title signals the refresh.
|
||||
const isLoading = loading && entities.length === 0;
|
||||
// Track whether we've ever received data. The full-table spinner should
|
||||
// only show on the truly initial load — not when a filter change
|
||||
// empties the client-side entity list before the backend responds.
|
||||
const hasHadData = useRef(false);
|
||||
if (entities.length > 0) {
|
||||
hasHadData.current = true;
|
||||
}
|
||||
const isLoading = loading && !hasHadData.current;
|
||||
|
||||
const tableColumns = useMemo(
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user