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:
@@ -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 =>
|
||||
|
||||
Reference in New Issue
Block a user