Skip to content

Commit

Permalink
chore: Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Al-Dani committed Aug 1, 2023
1 parent 6f0a5e8 commit 6bb84e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/table/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ const InternalTable = React.forwardRef(
resizableColumns && styles['table-layout-fixed'],
contentDensity === 'compact' && getVisualContextClassname('compact-table')
)}
aria-labelledby={isLabelledByHeader ? headingId : undefined}
{...getTableRoleProps({ tableRole, totalItemsCount, ariaLabel: ariaLabels?.tableLabel })}
{...getTableRoleProps({
tableRole,
totalItemsCount,
ariaLabel: ariaLabels?.tableLabel,
ariaLabelledBy: isLabelledByHeader && headerIdRef.current ? headerIdRef.current : undefined,
})}
>
<Thead
ref={theadRef}
Expand Down
2 changes: 2 additions & 0 deletions src/table/table-role/table-role-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type TableRole = 'table' | 'grid';
export function getTableRoleProps(options: {
tableRole: TableRole;
ariaLabel?: string;
ariaLabelledBy?: string;
totalItemsCount?: number;
}): React.TableHTMLAttributes<HTMLTableElement> {
const nativeProps: React.TableHTMLAttributes<HTMLTableElement> = {};
Expand All @@ -28,6 +29,7 @@ export function getTableRoleProps(options: {
nativeProps.role = options.tableRole;

nativeProps['aria-label'] = options.ariaLabel;
nativeProps['aria-labelledby'] = options.ariaLabelledBy;

// Incrementing the total count by one to account for the header row.
nativeProps['aria-rowcount'] = options.totalItemsCount ? options.totalItemsCount + 1 : -1;
Expand Down

0 comments on commit 6bb84e0

Please sign in to comment.