Skip to content
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

fix(material/select): make VoiceOver read options for selects in dialogs #20695

Merged
merged 1 commit into from
Oct 7, 2020

Conversation

jelbourn
Copy link
Member

@jelbourn jelbourn commented Oct 1, 2020

Fixes #20694

@zelliott noted that this issue was caused by aria-modal preventing
VoiceOver from accessing the select's listbox overlay. He suggested
using aria-owns to re-parent the overlay element to the select
trigger. I tried this and it works great.

@jelbourn jelbourn added P2 The issue is important to a large percentage of users, with a workaround Accessibility This issue is related to accessibility (a11y) area: material/select labels Oct 1, 2020
@jelbourn jelbourn requested review from zelliott and crisbeto October 1, 2020 00:38
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Oct 1, 2020
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM, but the lint check is failing.

@zelliott
Copy link
Collaborator

zelliott commented Oct 1, 2020

After having refreshed myself on the various combobox patterns, you're right that this does stray from ARIA 1.2 (which is what I'm guessing you're following here). I'm concerned that adding aria-owns here might cause some of the issues that the ARIA 1.0 combobox encountered, but I don't quite know enough about comboboxes to know for sure. @stevenyxu likely has some thoughts here.

@stevenyxu
Copy link
Contributor

stevenyxu commented Oct 1, 2020

I didn't realize the fix was already done so I took a stab at it and fwiw did confirm it fixes the issue. Here's my snippet (slightly different flavor than your fix but very similar):

<!-- removing aria-modal makes everything work, even if aria-owns is removed -->
<div aria-modal=true role=dialog>
  <button onclick="trigger.setAttribute('aria-activedescendant', 'opt1')"
          id=trigger
          role=combobox 
          aria-controls=listbox>
    select trigger
  </button>
  <!-- removing this breaks things, assuming aria-modal is set -->
  <div aria-owns=listbox></div>
</div>
<div role=listbox id=listbox>
  <div role=option id=opt1>opt 1</div>
  <div role=option id=opt2>opt 2</div>
</div>

+1 to Zack's point about the risk of appearing like a 1.0 combobox. In my separate discussions with Deque to get axe updated to permit the 1.2 pattern (dequelabs/axe-core#2505), one potential that was raised was to warn when people set aria-owns to nudge them to the 1.2 pattern instead. By being stuck in the middle here, overzealous heuristics may match you in a way you don't intend. An easy alternative is to put aria-owns on a roleless sibling to the mat-select, which is widely supported and doesn't result in mixing the 1.0 and 1.2 patterns. Of course, the combobox being the component's host element makes this slightly awkward.

@jelbourn
Copy link
Member Author

jelbourn commented Oct 1, 2020

@stevenyxu I moved aria-owns to a child element of the combobox without a role (.mat-select-trigger). This seems to work just as well on VoiceOver, NVDA, and ChromeVox.

@jelbourn
Copy link
Member Author

jelbourn commented Oct 1, 2020

Forgot to link the demo: https://material2-dev.firebaseapp.com/select

Fixes angular#20694

@zelliot noted that this issue was caused by `aria-modal` preventing
VoiceOver from accessing the select's listbox overlay. He suggested
using `aria-owns` to re-parent the overlay element to the select
trigger. I tried this and it works great.
@jelbourn jelbourn added the target: patch This PR is targeted for the next patch release label Oct 2, 2020
@zelliott
Copy link
Collaborator

zelliott commented Oct 2, 2020

If I understand @stevenyxu correctly, he recommended placing the aria-owns on a sibling of the combobox to avoid mixing the 1.0 and 1.2 patterns (but noted this would require some refactoring). As of now, aria-owns is still a child of the combobox, so IMO this still runs the risk of being flagged in an Axe check or as a WCAG failure potentially.

Regardless, I think this PR is still an improvement over the status quo, which renders popup listboxes wholly inaccessible within modal dialogs, so I wouldn't block on this concern.

@jelbourn
Copy link
Member Author

jelbourn commented Oct 2, 2020

Yeah, the only way I see the sibling approach working is if we manually insert a DOM element, which obviously isn't ideal. I figure it's better to hold off on that and see if anyone actually reports a problem.

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Oct 2, 2020
@wagnermaciel wagnermaciel added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Oct 7, 2020
@wagnermaciel wagnermaciel merged commit 33a43f7 into angular:master Oct 7, 2020
@rameshworsht
Copy link
Contributor

This PR does not resolve the main issue. Select component is not being read by screen readers. The solution would be to follow the suggestion by @zelliott.

@jelbourn
Copy link
Member Author

@rameshworsht feel free to file a new issue if you have steps to reproduce. I confirmed that this fix worked for VoiceOver, NVDA, and ChromeVox.

@rameshworsht
Copy link
Contributor

@jelbourn I used the like that you provided for the demo: https://material2-dev.firebaseapp.com/select and test it. Here is the GIF of the test.

@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 Nov 20, 2020
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 area: material/select cla: yes PR author has agreed to Google's Contributor License Agreement P2 The issue is important to a large percentage of users, with a workaround target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VoiceOver doesn't read MatSelect option inside of a dialog
7 participants