Skip to content

docs(a11y): Add a11y docs for table, expansion panel, dialog, chips, autocomplete… #6751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 6, 2017
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
7 changes: 7 additions & 0 deletions src/lib/autocomplete/autocomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ desired display value. Then bind it to the autocomplete's `displayWith` property
</md-optgroup>
</md-autocomplete>
```

### Accessibility
The input for autocomplete without text or labels should be given a meaningful label via
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be good to mention that the autocomplete trigger is given role="combobox"

`aria-label` or `aria-labelledby`.

Autocomplete trigger is given `role="combobox"`. The trigger sets `aria-owns` to the autocomplete's
id, and sets `aria-activedescendant` to the active option's id.
4 changes: 4 additions & 0 deletions src/lib/chips/chips.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ also gain focus when clicked, ensuring keyboard navigation starts at the appropr
The selected color of an `<md-chip>` can be changed by using the `color` property. By default, chips
use a neutral background color based on the current theme (light or dark). This can be changed to
`'primary'`, `'accent'`, or `'warn'`.

### Accessibility
A chip-list behaves as a `role="listbox"`, with each chip being a `role="option"`. The chip input
should have a placeholder or be given a meaningful label via `aria-label` or `aria-labelledby`.
19 changes: 19 additions & 0 deletions src/lib/dialog/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,22 @@ that the AOT compiler knows to create the `ComponentFactory` for it.
})
export class AppModule() {}
```

### Accessibility
By default, each dialog has `role="dialog"` on the root element. The role can be changed to
`alertdialog` via the `MdDialogConfig` when opening.

The `aria-label`, `aria-labelledby`, and `aria-describedby` attributes can all be set to the
dialog element via the `MdDialogConfig` as well. Each dialog should typically have a label
set via `aria-label` or `aria-labelledby`.

#### Focus management
By default, the first tabbable element within the dialog will receive focus upon open.

Tabbing through the elements of the dialog will keep focus inside of the dialog element,
wrapping back to the first tabbable element when reaching the end of the tab sequence.

#### Keyboard interaction
By default pressing the escape key will close the dialog. While this behavior can
be turned off via the `disableClose` option, users should generally avoid doing so
as it breaks the expected interaction pattern for screen-reader users.
9 changes: 9 additions & 0 deletions src/lib/expansion/expansion.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,12 @@ panel can be expanded at a given time:

</md-accordion>
```

### Accessibility
The expansion-panel aims to mimic the experience of the native `<details>` and `<summary>` elements.
The expansion panel header has `role="button"`. The expansion panel header has attribute
`aria-controls` with the expansion panel's id as value.

The expansion panel headers are buttons. Users can use the keyboard to activate the expansion panel
header to switch between expanded state and collapsed state. Because the header acts as a button,
additional interactive elements should not be put inside of the header.
10 changes: 10 additions & 0 deletions src/lib/input/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,13 @@ Here are the available global options:
| Name | Type | Description |
| ----------------- | -------- | ----------- |
| errorStateMatcher | Function | Returns a boolean specifying if the error should be shown |

### Accessibility
The `mdInput` directive works with native `<input>` to provide an accessible experience.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also mention that if you add a placeholder attribute to the input or a md-placeholder element in the form field that placeholder text will automatically be used as the label for the input. If you don't specify any placeholder you need to add aria-label aria-labeledby or <label for=...>

Possibly also worth mentioning that any md-error and md-hint are automatically added to the input's aria-describedby


If a placeholder attribute is added to the input, or a `md-placeholder` element is added
in the form field, the placeholder text will automatically be used as the label for the input.
If there's no placeholder specified, `aria-label`, `aria-labelledby` or `<label for=...>` should be
added.

Any `md-error` and `md-hint` are automatically added to the input's `aria-describedby`.
3 changes: 3 additions & 0 deletions src/lib/paginator/paginator.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ This will allow you to change the following:
1. The label for the length of each page.
2. The range text displayed to the user.
3. The tooltip messages on the navigation buttons.

### Accessibility
The `aria-label`s for next page and previous page buttons can be set in `MdPaginatorIntl`.
6 changes: 6 additions & 0 deletions src/lib/select/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ Here are the available global options:
- <kbd>DOWN_ARROW</kbd>: Focus next option
- <kbd>UP_ARROW</kbd>: Focus previous option
- <kbd>ENTER</kbd> or <kbd>SPACE</kbd>: Select focused item

### Accessibility
The select component without text or label should be given a meaningful label via
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the placeholder, hint, and error stuff will work the same way as input after the refactor. For now this is fine though

`aria-label` or `aria-labelledby`.

The select component has `role="listbox"` and options inside select have `role="option"`.
5 changes: 4 additions & 1 deletion src/lib/sort/sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ To prevent the user from clearing the sort sort state from an already sorted col
When used on an `md-table` header, it is not required to set an `md-sort-header` id on because
by default it will use the id of the column.

<!-- example(table-sorting) -->
<!-- example(table-sorting) -->

### Accessibility
The `aria-label` for the sort button can be set in `MdSortHeaderIntl`.
9 changes: 9 additions & 0 deletions src/lib/table/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ an update via the table's data source.
In the near future, we will provide a simplified version of the data-table with an easy-to-use
interface, material styling, array input, and more out-of-the-box features (sorting, pagination,
and selection).

### Accessibility
Tables without text or labels should be given a meaningful label via `aria-label` or
`aria-labelledby`. The `aria-readonly` defaults to `true` if it's not set.

Table's default role is `grid`, and it can be changed to `treegrid` through `role` attribute.

`md-table` does not manage any focus/keyboard interaction on its own. Users can add desired
focus/keyboard interactions in their application.
13 changes: 13 additions & 0 deletions src/lib/tabs/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,16 @@ provides a tab-like UI for navigating between routes.
The tab-nav-bar is not tied to any particular router; it works with normal `<a>` elements and uses
the `active` property to determine which tab is currently active. The corresponding
`<router-outlet>` can be placed anywhere in the view.

### Accessibility
Tabs without text or labels should be given a meaningful label via `aria-label` or
`aria-labelledby`. For `MdTabNav`, the `<nav>` element should have a label as well.


#### Keyboard shortcuts

| Shortcut | Action |
|----------------------|----------------------------|
| `LEFT_ARROW` | Move focus to previous tab |
| `RIGHT_ARROW` | Move focus to next tab |
| `SPACE` or 'ENTER' | Switch to focused tab |