Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type SharedDivProps = Pick<
| 'role'
| 'aria-label'
| 'aria-labelledby'
| 'aria-description'
| 'aria-describedby'
| 'aria-rowcount'
| 'className'
Expand Down Expand Up @@ -260,6 +261,7 @@ function DataGrid<R, SR, K extends Key>(
role: rawRole,
'aria-label': ariaLabel,
'aria-labelledby': ariaLabelledBy,
'aria-description': ariaDescription,
'aria-describedby': ariaDescribedBy,
'aria-rowcount': rawAriaRowCount,
'data-testid': testId
Expand Down Expand Up @@ -1076,10 +1078,12 @@ function DataGrid<R, SR, K extends Key>(
selectedPosition.idx === -1 && selectedPosition.rowIdx !== minRowIdx - 1;

return (
// biome-ignore lint/a11y/useValidAriaProps: aria-description is a valid prop
<div
role={role}
aria-label={ariaLabel}
aria-labelledby={ariaLabelledBy}
aria-description={ariaDescription}
aria-describedby={ariaDescribedBy}
aria-multiselectable={isSelectable ? true : undefined}
aria-colcount={columns.length}
Expand Down
18 changes: 18 additions & 0 deletions test/browser/label.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { getGrid, setup } from './utils';

test('should set label and description', () => {
setup({
rows: [],
columns: [],
'aria-label': 'label',
'aria-labelledby': 'labelledby',
'aria-description': 'description',
'aria-describedby': 'describedby'
});

const grid = getGrid().element();
expect(grid).toHaveAttribute('aria-label', 'label');
expect(grid).toHaveAttribute('aria-labelledby', 'labelledby');
expect(grid).toHaveAttribute('aria-description', 'description');
expect(grid).toHaveAttribute('aria-describedby', 'describedby');
});