There are a few issues in mdChips that make them hard to use with a screen reader, including:
This is complicated by the fact that there are three different ways a Chips component can get a native <input>, which is the thing requiring a label:
<input>.<input>.<input>.If there is a placeholder on the <md-chips> or <md-contact-chips>, we can copy that text to the child input IF it doesn't already have aria-label (likely when manually adding an input). If the parent has aria-label supplied, that should be moved to the input instead of the placeholder.
Bonus points for supporting aria-labelledby. But I can't even get a reliable aria-label in all three scenarios.
An accessible, rendered chips component would look like this (regardless of API used by the developer):
<md-chips ng-model="ctrl.roFruitNames" tabindex="-1">
<md-chips-wrap ng-if="!$mdChipsCtrl.readonly || $mdChipsCtrl.items.length > 0"
ng-keydown="$mdChipsCtrl.chipKeydown($event)"
ng-class="{ 'md-focused': $mdChipsCtrl.hasFocus() }" class="md-chips">
<md-chip ng-repeat="$chip in $mdChipsCtrl.items" index="0"
ng-class="{'md-focused': $mdChipsCtrl.selectedChip == $index}"
class="md-chip">
<div class="md-chip-content" tabindex="-1"
ng-focus="!$mdChipsCtrl.readonly && $mdChipsCtrl.selectChip($index)">
<md-chip-template>
<strong>Apple</strong>
<em>(fruit)</em>
</md-chip-template>
</div>
<div class="md-chip-remove-container">
<button class="md-chip-remove"
ng-click="$mdChipsCtrl.removeChipAndFocusInput($$replacedScope.$index)"
type="button"
aria-hidden="true" tabindex="-1"
id="uniqueButtonID">
<md-icon md-svg-icon="md-close" aria-hidden="true"></md-icon>
</button>
</div>
</md-chip>
<div class="md-chip-input-container">
<input ng-model="$mdChipsCtrl.chipBuffer"
ng-focus="$mdChipsCtrl.onInputFocus()"
ng-blur="$mdChipsCtrl.onInputBlur()"
ng-keydown="$mdChipsCtrl.inputKeydown($event)"
aria-label="Some label"
placeholder="Placeholder"
aria-describedby="deleteHintText_0">
<div id="deleteHintText_0" style="display: none;">
Press delete to remove {{ lastChip.name }}
</div>
</div>
</md-chips-wrap>
</md-chips>
The major differences are:
aria-label, different from the placeholder (it should support both but default to copying from placeholder).aria-describedby pointing to a new hint text node telling a screen reader user that the delete key will remove the last chip added (with a unique name).md-chip-remove buttons don't need visually-hidden text with aria-hidden and tabindex="-1".@ThomasBurleson aria-label isn't making its way to the input in the chips demo that uses autocomplete. The static chips demo also throws a warning. Can you take a look at those?
@marcysutton @ThomasBurleson any progress on this?
@ilanbiala - The team is focused and working very hard on features and issue resolution for v1.0. Issue comments posted requesting progress/status updates are not helpful.
@ThomasBurleson this is marked for 0.11.0, which is the next release and the latest commit was made over a month ago, I'm trying to find out if any progress has been made that hasn't been reported or if there are issues and maybe someone from the community can help.
I am scheduling some other chips issues for RC6 and will try to look at this then.
Chips currently have a lot of accessibility issues. This issue is helpful as it indicates some possible solutions, so I am re-opening it.
I've posted PR https://github.com/angular/material/pull/11422 to address these issues and more. I'd appreciate some assistance with the review 馃槃