Skip to content

Commit 5527e22

Browse files
authored
docs(a11y): Add a11y docs for table, expansion panel, dialog, chips, autocomplete… (#6751)
* Add a11y docs for table, expansion panel, dialog, chips, autocomplete, and select * address comments
1 parent 3989153 commit 5527e22

File tree

10 files changed

+84
-1
lines changed

10 files changed

+84
-1
lines changed

src/lib/autocomplete/autocomplete.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,10 @@ desired display value. Then bind it to the autocomplete's `displayWith` property
9595
</md-optgroup>
9696
</md-autocomplete>
9797
```
98+
99+
### Accessibility
100+
The input for autocomplete without text or labels should be given a meaningful label via
101+
`aria-label` or `aria-labelledby`.
102+
103+
Autocomplete trigger is given `role="combobox"`. The trigger sets `aria-owns` to the autocomplete's
104+
id, and sets `aria-activedescendant` to the active option's id.

src/lib/chips/chips.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ also gain focus when clicked, ensuring keyboard navigation starts at the appropr
3838
The selected color of an `<md-chip>` can be changed by using the `color` property. By default, chips
3939
use a neutral background color based on the current theme (light or dark). This can be changed to
4040
`'primary'`, `'accent'`, or `'warn'`.
41+
42+
### Accessibility
43+
A chip-list behaves as a `role="listbox"`, with each chip being a `role="option"`. The chip input
44+
should have a placeholder or be given a meaningful label via `aria-label` or `aria-labelledby`.

src/lib/dialog/dialog.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,22 @@ that the AOT compiler knows to create the `ComponentFactory` for it.
126126
})
127127
export class AppModule() {}
128128
```
129+
130+
### Accessibility
131+
By default, each dialog has `role="dialog"` on the root element. The role can be changed to
132+
`alertdialog` via the `MdDialogConfig` when opening.
133+
134+
The `aria-label`, `aria-labelledby`, and `aria-describedby` attributes can all be set to the
135+
dialog element via the `MdDialogConfig` as well. Each dialog should typically have a label
136+
set via `aria-label` or `aria-labelledby`.
137+
138+
#### Focus management
139+
By default, the first tabbable element within the dialog will receive focus upon open.
140+
141+
Tabbing through the elements of the dialog will keep focus inside of the dialog element,
142+
wrapping back to the first tabbable element when reaching the end of the tab sequence.
143+
144+
#### Keyboard interaction
145+
By default pressing the escape key will close the dialog. While this behavior can
146+
be turned off via the `disableClose` option, users should generally avoid doing so
147+
as it breaks the expected interaction pattern for screen-reader users.

src/lib/expansion/expansion.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,12 @@ panel can be expanded at a given time:
9898

9999
</md-accordion>
100100
```
101+
102+
### Accessibility
103+
The expansion-panel aims to mimic the experience of the native `<details>` and `<summary>` elements.
104+
The expansion panel header has `role="button"`. The expansion panel header has attribute
105+
`aria-controls` with the expansion panel's id as value.
106+
107+
The expansion panel headers are buttons. Users can use the keyboard to activate the expansion panel
108+
header to switch between expanded state and collapsed state. Because the header acts as a button,
109+
additional interactive elements should not be put inside of the header.

src/lib/input/input.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,13 @@ Here are the available global options:
150150
| Name | Type | Description |
151151
| ----------------- | -------- | ----------- |
152152
| errorStateMatcher | Function | Returns a boolean specifying if the error should be shown |
153+
154+
### Accessibility
155+
The `mdInput` directive works with native `<input>` to provide an accessible experience.
156+
157+
If a placeholder attribute is added to the input, or a `md-placeholder` element is added
158+
in the form field, the placeholder text will automatically be used as the label for the input.
159+
If there's no placeholder specified, `aria-label`, `aria-labelledby` or `<label for=...>` should be
160+
added.
161+
162+
Any `md-error` and `md-hint` are automatically added to the input's `aria-describedby`.

src/lib/paginator/paginator.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ This will allow you to change the following:
2424
1. The label for the length of each page.
2525
2. The range text displayed to the user.
2626
3. The tooltip messages on the navigation buttons.
27+
28+
### Accessibility
29+
The `aria-label`s for next page and previous page buttons can be set in `MdPaginatorIntl`.

src/lib/select/select.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@ Here are the available global options:
9292
- <kbd>DOWN_ARROW</kbd>: Focus next option
9393
- <kbd>UP_ARROW</kbd>: Focus previous option
9494
- <kbd>ENTER</kbd> or <kbd>SPACE</kbd>: Select focused item
95+
96+
### Accessibility
97+
The select component without text or label should be given a meaningful label via
98+
`aria-label` or `aria-labelledby`.
99+
100+
The select component has `role="listbox"` and options inside select have `role="option"`.

src/lib/sort/sort.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ To prevent the user from clearing the sort sort state from an already sorted col
3232
When used on an `md-table` header, it is not required to set an `md-sort-header` id on because
3333
by default it will use the id of the column.
3434

35-
<!-- example(table-sorting) -->
35+
<!-- example(table-sorting) -->
36+
37+
### Accessibility
38+
The `aria-label` for the sort button can be set in `MdSortHeaderIntl`.

src/lib/table/table.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,12 @@ an update via the table's data source.
4545
In the near future, we will provide a simplified version of the data-table with an easy-to-use
4646
interface, material styling, array input, and more out-of-the-box features (sorting, pagination,
4747
and selection).
48+
49+
### Accessibility
50+
Tables without text or labels should be given a meaningful label via `aria-label` or
51+
`aria-labelledby`. The `aria-readonly` defaults to `true` if it's not set.
52+
53+
Table's default role is `grid`, and it can be changed to `treegrid` through `role` attribute.
54+
55+
`md-table` does not manage any focus/keyboard interaction on its own. Users can add desired
56+
focus/keyboard interactions in their application.

src/lib/tabs/tabs.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,16 @@ provides a tab-like UI for navigating between routes.
7979
The tab-nav-bar is not tied to any particular router; it works with normal `<a>` elements and uses
8080
the `active` property to determine which tab is currently active. The corresponding
8181
`<router-outlet>` can be placed anywhere in the view.
82+
83+
### Accessibility
84+
Tabs without text or labels should be given a meaningful label via `aria-label` or
85+
`aria-labelledby`. For `MdTabNav`, the `<nav>` element should have a label as well.
86+
87+
88+
#### Keyboard shortcuts
89+
90+
| Shortcut | Action |
91+
|----------------------|----------------------------|
92+
| `LEFT_ARROW` | Move focus to previous tab |
93+
| `RIGHT_ARROW` | Move focus to next tab |
94+
| `SPACE` or 'ENTER' | Switch to focused tab |

0 commit comments

Comments
 (0)