From 88976d8c357b8cf496bc8b4c83e597bc1985da7e Mon Sep 17 00:00:00 2001 From: crisbeto Date: Mon, 14 Aug 2017 23:34:11 +0200 Subject: [PATCH] fix(chips): set appropriate aria-orientation Based on the [accessibility guidelines](https://www.w3.org/TR/wai-aria-practices-1.1/#Listbox), the `listbox` role has a default `aria-orientation` of `vertical`, however the chips in a chip list are horizontal. --- src/demo-app/chips/chips-demo.html | 2 +- src/lib/chips/chip-list.ts | 4 ++++ src/lib/chips/chips.md | 13 ++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/demo-app/chips/chips-demo.html b/src/demo-app/chips/chips-demo.html index 15fb7dea6e8b..c8108ef1b343 100644 --- a/src/demo-app/chips/chips-demo.html +++ b/src/demo-app/chips/chips-demo.html @@ -102,7 +102,7 @@

Stacked Chips

(focus) event to run custom code.

- + {{aColor.name}} diff --git a/src/lib/chips/chip-list.ts b/src/lib/chips/chip-list.ts index 4d35584f9fb6..b59791a830e8 100644 --- a/src/lib/chips/chip-list.ts +++ b/src/lib/chips/chip-list.ts @@ -45,6 +45,7 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion'; host: { '[attr.tabindex]': '_tabIndex', 'role': 'listbox', + '[attr.aria-orientation]': 'ariaOrientation', 'class': 'mat-chip-list', '(focus)': 'focus()', @@ -82,6 +83,9 @@ export class MdChipList implements AfterContentInit, OnDestroy { /** The chip components contained within this chip list. */ chips: QueryList; + /** Orientation of the chip list. */ + @Input('aria-orientation') ariaOrientation: 'horizontal' | 'vertical' = 'horizontal'; + constructor(protected _renderer: Renderer2, protected _elementRef: ElementRef, @Optional() private _dir: Directionality) { } diff --git a/src/lib/chips/chips.md b/src/lib/chips/chips.md index 58727d319162..c03c805f7fca 100644 --- a/src/lib/chips/chips.md +++ b/src/lib/chips/chips.md @@ -33,8 +33,19 @@ chips are neither selectable nor focusable. Currently, disabled chips receive no Users can move through the chips using the arrow keys and select/deselect them with the space. Chips also gain focus when clicked, ensuring keyboard navigation starts at the appropriate chip. +### Orientation +If you want the chips in the list to be stacked vertically, instead of horizontally, you can apply +the `mat-chip-list-stacked` class, as well as the `aria-orientation="vertical"` attribute: + +```html + + Papadum + Naan + Dal + +``` ### Theming The selected color of an `` 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 +use a neutral background color based on the current theme (light or dark). This can be changed to `'primary'`, `'accent'`, or `'warn'`.