refactor(ui): consolidate live region label logic

Move initial loading label into useLiveRegionLabel so all live
region logic is in one place.

Signed-off-by: Jonathan Roebuck <jroebuck@spotify.com>
This commit is contained in:
Jonathan Roebuck
2026-03-13 09:57:25 +00:00
parent 36d9e1b56e
commit a688c806bc
@@ -62,8 +62,13 @@ function useDisabledRows<T extends TableItem>({
function useLiveRegionLabel(
pagination: TablePaginationType,
isStale: boolean,
isLoading: boolean,
hasData: boolean,
): string {
if (isLoading) {
return 'Loading table data.';
}
if (!hasData || pagination.type === 'none') {
return '';
}
@@ -126,9 +131,12 @@ export function Table<T extends TableItem>({
);
}
const liveRegionLabel = isInitialLoading
? 'Loading table data.'
: useLiveRegionLabel(pagination, isStale, data !== undefined);
const liveRegionLabel = useLiveRegionLabel(
pagination,
isStale,
isInitialLoading,
data !== undefined,
);
const manualColumnSizing = columnConfig.some(
col =>