From a688c806bcae348f65f54103d371db629a2d676e Mon Sep 17 00:00:00 2001 From: Jonathan Roebuck Date: Fri, 13 Mar 2026 09:57:25 +0000 Subject: [PATCH] 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 --- .../ui/src/components/Table/components/Table.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/Table/components/Table.tsx b/packages/ui/src/components/Table/components/Table.tsx index e5f519b8e5..6ad1fa96ae 100644 --- a/packages/ui/src/components/Table/components/Table.tsx +++ b/packages/ui/src/components/Table/components/Table.tsx @@ -62,8 +62,13 @@ function useDisabledRows({ 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({ ); } - const liveRegionLabel = isInitialLoading - ? 'Loading table data.' - : useLiveRegionLabel(pagination, isStale, data !== undefined); + const liveRegionLabel = useLiveRegionLabel( + pagination, + isStale, + isInitialLoading, + data !== undefined, + ); const manualColumnSizing = columnConfig.some( col =>