Skip to content

Commit 1b6b270

Browse files
tinayuangaojelbourn
authored andcommitted
docs(a11y): add accessibility sections to datepicker, menu, slide … (#6710)
1 parent cd16ec6 commit 1b6b270

File tree

6 files changed

+80
-0
lines changed

6 files changed

+80
-0
lines changed

src/lib/datepicker/datepicker.md

+49
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,52 @@ application root module.
229229
})
230230
export class MyApp {}
231231
```
232+
### Accessibility
233+
The `MdDatepickerInput` directive adds `aria-haspopup` attribute to the native input element, and it
234+
triggers a calendar dialog with `role="dialog"`.
235+
236+
`MdDatepickerIntl` includes strings that are used for `aria-label`s. The datepicker input
237+
should have a placeholder or be given a meaningful label via `aria-label`, `aria-labelledby` or
238+
`MdDatepickerIntl`.
239+
240+
#### Keyboard shortcuts
241+
The keyboard shortcuts to handle datepicker are:
242+
243+
| Shortcut | Action |
244+
|----------------------|-------------------------------------|
245+
| `ALT` + `DOWN_ARROW` | Open the calendar pop-up |
246+
| `ESCAPE` | Close the calendar pop-up |
247+
248+
249+
In month view:
250+
251+
| Shortcut | Action |
252+
|----------------------|-------------------------------------|
253+
| `LEFT_ARROW` | Go to previous day |
254+
| `RIGHT_ARROW` | Go to next day |
255+
| `UP_ARROW` | Go to same day in the previous week |
256+
| `DOWN_ARROW` | Go to same day in the next week |
257+
| `HOME` | Go to the first day of the month |
258+
| `END` | Go to the last day of the month |
259+
| `PAGE_UP` | Go to previous month |
260+
| `ALT` + `PAGE_UP` | Go to previous year |
261+
| `PAGE_DOWN` | Go to next month |
262+
| `ALT` + `PAGE_DOWN` | Go to next year |
263+
| `ENTER` | Select current date |
264+
265+
266+
In year view:
267+
268+
| Shortcut | Action |
269+
|----------------------|-------------------------------------|
270+
| `LEFT_ARROW` | Go to previous month |
271+
| `RIGHT_ARROW` | Go to next month |
272+
| `UP_ARROW` | Go to previous 6 months |
273+
| `DOWN_ARROW` | Go to next 6 months |
274+
| `HOME` | Go to the first month of the year |
275+
| `END` | Go to the last month of the year |
276+
| `PAGE_UP` | Go to previous year |
277+
| `ALT` + `PAGE_UP` | Go to previous 10 years |
278+
| `PAGE_DOWN` | Go to next year |
279+
| `ALT` + `PAGE_DOWN` | Go to next 10 years |
280+
| `ENTER` | Select current month |

src/lib/menu/menu.md

+4
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,7 @@ that should trigger the sub-menu:
9898
- <kbd>RIGHT_ARROW</kbd>: Opens the menu item's sub-menu
9999
- <kbd>LEFT_ARROW</kbd>: Closes the current menu, if it is a sub-menu.
100100
- <kbd>ENTER</kbd>: Activates the focused menu item
101+
102+
### Accessibility
103+
Menu triggers or menu items without text or labels should be given a meaningful label via
104+
`aria-label` or `aria-labelledby`.

src/lib/slide-toggle/slide-toggle.md

+8
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ and `ReactiveFormsModule`.
2222
### Theming
2323
The color of a `<md-slide-toggle>` can be changed by using the `color` property. By default,
2424
slide-toggles use the theme's accent color. This can be changed to `'primary'` or `'warn'`.
25+
26+
### Accessibility
27+
The `<md-slide-toggle>` uses an internal `<input type="checkbox">` to provide an accessible
28+
experience. This internal checkbox receives focus and is automatically labelled by the text content
29+
of the `<md-slide-toggle>` element.
30+
31+
Slide toggles without text or labels should be given a meaningful label via `aria-label` or
32+
`aria-labelledby`.

src/lib/slider/slider.md

+4
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,7 @@ The slider has the following keyboard bindings:
8585
| Page down | Decrement the slider value by 10 steps. |
8686
| End | Set the value to the maximum possible. |
8787
| Home | Set the value to the minimum possible. |
88+
89+
### Accessibility
90+
Sliders without text or labels should be given a meaningful label via `aria-label` or
91+
`aria-labelledby`.

src/lib/snack-bar/snack-bar.md

+5
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@ export class MessageArchivedComponent {
7272
constructor(@Inject(MD_SNACK_BAR_DATA) public data: any) { }
7373
}
7474
```
75+
### Accessibility
76+
Snack-bar messages are announced via an `aria-live` region. Focus is not moved to
77+
the snack-bar element, as this would be disruptive to a user in the middle of a
78+
workflow. For any action offered in the snack-bar, the application should offer the
79+
user an alternative way to perform the action (typically via keyboard shortcut).

src/lib/toolbar/toolbar.md

+10
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,13 @@ easily accomplished with `display: flex`:
4949
The color of a `<md-toolbar>` can be changed by using the `color` property. By default, toolbars
5050
use a neutral background color based on the current theme (light or dark). This can be changed to
5151
`'primary'`, `'accent'`, or `'warn'`.
52+
53+
### Accessibility
54+
By default, the toolbar assumes that it will be used in a purely decorative fashion and thus sets
55+
no roles, ARIA attributes, or keyboard shortcuts. This is equivalent to having a sequence of `<div>`
56+
elements on the page.
57+
58+
Generally, the toolbar is used as a header where `role="header"` would be appropriate.
59+
60+
Only if the use-case of the toolbar match that of role="toolbar", the user should add the role and
61+
an appropriate label via `aria-label` or `aria-labelledby`.

0 commit comments

Comments
 (0)