Skip to content

Commit 249a1de

Browse files
committed
fix(list): use correct aria-orientation to improve accessibility
The `aria-orientation` attribute is simply not valid for `role="group"` (which is used for checkboxes), according to the ARIA spec. This is regardless of how the keyboard navigation actually works.
1 parent 98e2c8c commit 249a1de

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/components/list/list-renderer.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,26 @@ export class ListRenderer {
4242
<ul
4343
class="mdc-deprecated-list"
4444
role={role}
45-
aria-orientation="vertical"
45+
aria-orientation={this.getAriaOrientation(role)}
4646
>
4747
{items.map(this.renderListItem)}
4848
</ul>
4949
);
5050
}
5151

52+
/**
53+
* `aria-orientation` is valid for `listbox` and `radiogroup`,
54+
* but not for group (used for checkboxes).
55+
* @param role
56+
*/
57+
private getAriaOrientation = (role: string) => {
58+
if (role === 'listbox' || role === 'radiogroup') {
59+
return 'vertical';
60+
} else {
61+
return null;
62+
}
63+
};
64+
5265
/**
5366
* Determine which ListItem should have the `tab-index` attribute set,
5467
* and return the index at which that ListItem is located in `items`.

0 commit comments

Comments
 (0)