Skip to content

fix(option): Remove aria-selected='false' in single-selection mode #15617

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 1 commit into from
Apr 2, 2019

Conversation

vanessanschmitt
Copy link
Collaborator

Add an Input to optionally remove the aria-selected attribute from unselected options.
The default behavior is unchanged. Motivation: the screen reader NVDA announces 'not selected'
on any element that has aria-selected='false', which is disruptive when a user is navigating
through a long list of options. The W3 aria best practices example only uses aria-selected='true',
false is implicit:
https://www.w3.org/TR/wai-aria-practices/examples/listbox/listbox-collapsible.html

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 26, 2019
@stevenyxu
Copy link
Contributor

Worth adding that aria-selected=false has some precedent for being used in multiple select cases https://www.w3.org/TR/2017/WD-wai-aria-practices-1.1-20170628/examples/listbox/listbox.html. If Angular Material team agrees, I'd suggest omitting aria-selected=false on single select and include it on multiple. This only affects MatSelect; the same change would need to be done in other components that use MatOption directly.

@crisbeto
Copy link
Member

crisbeto commented Mar 26, 2019

Agreed with @stevenyxu that we should omit the aria-selected in single-selection mode, rather than introduce another option. Note that mat-autocomplete also uses mat-option, but the same change should apply there.

Also cc @jelbourn

@vanessanschmitt vanessanschmitt force-pushed the vschmitt-aria-selected branch from a3a4b8e to 7b5b0b5 Compare March 26, 2019 21:21
@jelbourn
Copy link
Member

I also agree that we should just do this by default based on the single selection vs. multi-selection distinction. That would avoid adding the new API surface to the component.

@jelbourn jelbourn added Accessibility This issue is related to accessibility (a11y) P2 The issue is important to a large percentage of users, with a workaround G This is is related to a Google internal issue labels Mar 26, 2019
@stevenyxu
Copy link
Contributor

Making sure MatSelect and MatAutocomplete work as expected as part of this change seems sensible, and I think everyone has agreed on the single vs. multiple differentiation. As for opening a new input on MatOption, it's not clear to me there's a way around this. MatOption maintains its own selected state and for it to bind its own aria-selected attribute is more coherent than e.g., exposing an API to set the attribute to MatSelect/MatAutcomplete.

Is there an alternative that allows MatOption to omit aria-selected=false in single MatSelect case and have it in multiple MatSelect without adding to the API?

The only potential suggestion I had, though I don't feel strongly, is to make it a positive or enum API rather than a negative one like "disableAriaSelectedExplicitFalse", so more like

@Input() ariaSelectedMode: 'never'|'expanded'|'always' = 'always';

I considered suggesting an internal API, but there is a preference to make it public since our use case involves MatOption on its own, without MatSelect.

@crisbeto
Copy link
Member

crisbeto commented Mar 26, 2019

The MatOption has a _parent property that has some info like whether the parent component is in multi-selection mode. That should be enough information to determine whether or not to add the attribute.

@vanessanschmitt
Copy link
Collaborator Author

Thanks for the suggestions, everyone! I'll investigate if having our component implement MatOptionParentComponent will allow us to just rely on the single vs. multiple distinction in the option without exposing an Input.

@vanessanschmitt vanessanschmitt force-pushed the vschmitt-aria-selected branch 2 times, most recently from bdf18a2 to 1e20ed2 Compare March 26, 2019 23:26
@vanessanschmitt
Copy link
Collaborator Author

Using the single vs. multiple info provided in the _parent should work for our use case! I updated the commit accordingly.

@vanessanschmitt vanessanschmitt force-pushed the vschmitt-aria-selected branch from 1e20ed2 to 0807dce Compare March 27, 2019 16:21
@vanessanschmitt vanessanschmitt changed the title feat(option): add Input to remove aria-selected='false' feat(option): Remove aria-selected='false' in single-selection mode Mar 27, 2019
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

Looks good, just a few small comments

crisbeto added a commit to crisbeto/material2 that referenced this pull request Mar 27, 2019
…tion mode

Along the same lines as angular#15617 since the setup between `mat-select` and `mat-chip-list` fairly similar. Removes the `aria-selected` from deselected chips in single selection mode in order to reduce the amount of noise for screen reader users.
crisbeto added a commit to crisbeto/material2 that referenced this pull request Mar 27, 2019
…tion mode

Along the same lines as angular#15617 since the setup between `mat-select` and `mat-chip-list` fairly similar. Removes the `aria-selected` from deselected chips in single selection mode in order to reduce the amount of noise for screen reader users.
jelbourn pushed a commit that referenced this pull request Mar 28, 2019
…tion mode (#15634)

Along the same lines as #15617 since the setup between `mat-select` and `mat-chip-list` fairly similar. Removes the `aria-selected` from deselected chips in single selection mode in order to reduce the amount of noise for screen reader users.
@vanessanschmitt vanessanschmitt force-pushed the vschmitt-aria-selected branch from 0807dce to f0eb6b1 Compare March 28, 2019 18:41
@vanessanschmitt vanessanschmitt changed the title feat(option): Remove aria-selected='false' in single-selection mode fix(option): Remove aria-selected='false' in single-selection mode Mar 28, 2019
Remove the aria-selected attribute from unselected options in single
selection mode. The multi-selection behavior is unchanged. Motivation:
the screen reader NVDA announces 'not selected' on any element that has
aria-selected='false', which is disruptive when a user is navigating
through a long list of options. The W3 aria best practices example only
uses aria-selected='true for single selection', false is implicit:
https://www.w3.org/TR/wai-aria-practices/examples/listbox/listbox-collapsible.html
@vanessanschmitt vanessanschmitt force-pushed the vschmitt-aria-selected branch from f0eb6b1 to 0d666a5 Compare March 28, 2019 18:47
@vanessanschmitt
Copy link
Collaborator Author

Just commenting to note that I made the requested changes.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Apr 1, 2019
@mmalerba mmalerba merged commit 0f569ff into angular:master Apr 2, 2019
jelbourn pushed a commit that referenced this pull request Apr 4, 2019
…tion mode (#15634)

Along the same lines as #15617 since the setup between `mat-select` and `mat-chip-list` fairly similar. Removes the `aria-selected` from deselected chips in single selection mode in order to reduce the amount of noise for screen reader users.
jelbourn pushed a commit that referenced this pull request Apr 4, 2019
…15617)

Add an Input to optionally remove the aria-selected attribute from unselected options.
The default behavior is unchanged. Motivation: the screen reader NVDA announces 'not selected'
on any element that has aria-selected='false', which is disruptive when a user is navigating
through a long list of options. The W3 aria best practices example only uses aria-selected='true',
false is implicit:
https://www.w3.org/TR/wai-aria-practices/examples/listbox/listbox-collapsible.html
@vanessanschmitt vanessanschmitt deleted the vschmitt-aria-selected branch June 25, 2019 21:45
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Accessibility This issue is related to accessibility (a11y) action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants