Skip to content

Commit ad30bbf

Browse files
authored
fix/dg col selector accessibility (#2024)
2 parents 0c9e0e9 + 8ccd212 commit ad30bbf

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

packages/pluggableWidgets/datagrid-web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- We improved accessibility on column selector, added aria-attributes and changed the role to 'menuitemcheckbox'.
12+
913
### Added
1014

1115
- We added accessibility support for column headers when single selection is enabled, making sure the purpose of the column is announced.

packages/pluggableWidgets/datagrid-web/src/components/ColumnSelector.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ export function ColumnSelector(props: ColumnSelectorProps): ReactElement {
160160
setShow(false);
161161
}
162162
}}
163-
role="menuitem"
163+
role="menuitemcheckbox"
164+
aria-checked={isVisible}
165+
aria-disabled={isLastVisibleColumn}
164166
tabIndex={0}
165167
>
166168
<input
@@ -170,6 +172,7 @@ export function ColumnSelector(props: ColumnSelectorProps): ReactElement {
170172
style={{ pointerEvents: "none" }}
171173
type="checkbox"
172174
tabIndex={-1}
175+
aria-hidden="true"
173176
onChange={onChangeStub}
174177
/>
175178
<label htmlFor={`${props.id}_checkbox_toggle_${index}`} style={{ pointerEvents: "none" }}>

packages/pluggableWidgets/datagrid-web/src/components/__tests__/ColumnSelector.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("Column Selector", () => {
3737

3838
jest.advanceTimersByTime(100);
3939

40-
const items = screen.getAllByRole("menuitem");
40+
const items = screen.getAllByRole("menuitemcheckbox");
4141
expect(items[0]).toHaveFocus();
4242
});
4343

@@ -52,7 +52,7 @@ describe("Column Selector", () => {
5252

5353
jest.advanceTimersByTime(100);
5454

55-
const items = screen.getAllByRole("menuitem");
55+
const items = screen.getAllByRole("menuitemcheckbox");
5656
expect(items[0]).toHaveFocus();
5757

5858
await act(async () => {
@@ -92,7 +92,7 @@ describe("Column Selector", () => {
9292
});
9393
jest.advanceTimersByTime(100);
9494

95-
const items = screen.getAllByRole("menuitem");
95+
const items = screen.getAllByRole("menuitemcheckbox");
9696
expect(items[0]).toHaveFocus();
9797

9898
await act(async () => {
@@ -149,7 +149,7 @@ describe("Column Selector", () => {
149149
});
150150
jest.advanceTimersByTime(100);
151151

152-
const items = screen.getAllByRole("menuitem");
152+
const items = screen.getAllByRole("menuitemcheckbox");
153153
expect(items).toHaveLength(3);
154154
expect(items[0]).toHaveFocus();
155155

0 commit comments

Comments
 (0)