Skip to content

fix(material/dialog): dialog content not being read out by screen readers #14533

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

Closed

Conversation

crisbeto
Copy link
Member

Currently we focus the first focusable element inside a dialog as per the accessibility recommendations, however moving focus to the first item causes some screen readers not to read out the rest of the dialog content. These changes switch to focusing the dialog container by default which allows screen readers to read out everything. If users press tab, they'll land on the first tabbable element anyways. The old behavior can still be opted into via the autoFocus option.

Fixes #10591.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Dec 15, 2018
@crisbeto crisbeto requested a review from jelbourn as a code owner December 15, 2018 16:10
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 15, 2018
/** Whether the dialog should focus the first focusable element on open. */
autoFocus?: boolean = true;
autoFocus?: boolean = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

@jelbourn these changes are based on our discussion from a while back. An alternate approach we can take is to move focus to the first focusable element immediately, rather than assigning it to the dialog container in between. This allows the screen reader to read out a bit more, but still not everything (it reads out the dialog header and buttons, but it skips the content vs the behavior in master where only the button is read out).

I opted for this approach, because it allows for all the content to be read out, even though it's not the recommended one.

@crisbeto crisbeto force-pushed the 10591/dialog-content-screen-readers branch 2 times, most recently from b8d9d85 to 9e9c39c Compare December 15, 2018 16:23
@crisbeto crisbeto added the Accessibility This issue is related to accessibility (a11y) label Dec 15, 2018
@jelbourn
Copy link
Member

Which screenreaders did you test this in?

@crisbeto
Copy link
Member Author

I've been testing it with NVDA.

@ngbot
Copy link

ngbot bot commented Jan 11, 2019

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

2 similar comments
@ngbot
Copy link

ngbot bot commented Jan 11, 2019

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@ngbot
Copy link

ngbot bot commented Jan 11, 2019

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@crisbeto crisbeto force-pushed the 10591/dialog-content-screen-readers branch from 9e9c39c to 110a8ea Compare January 13, 2019 17:20
@crisbeto crisbeto force-pushed the 10591/dialog-content-screen-readers branch from 110a8ea to b582aea Compare April 3, 2019 21:07
@mmalerba mmalerba added aaa and removed aaa labels Apr 25, 2019
@crisbeto crisbeto force-pushed the 10591/dialog-content-screen-readers branch 2 times, most recently from 7de991e to 4534cd8 Compare May 26, 2019 13:11
@andrewseguin andrewseguin added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent G This is is related to a Google internal issue labels May 30, 2019
@crisbeto crisbeto force-pushed the 10591/dialog-content-screen-readers branch from 4534cd8 to 5f5be59 Compare June 20, 2019 21:03
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 pr: lgtm action: merge The PR is ready for merge by the caretaker labels Sep 5, 2019
@benjspriggs
Copy link

What's the status on this PR?

@mmalerba mmalerba removed the lgtm label Jul 31, 2020
@jelbourn
Copy link
Member

It looks like this change breaks a large number of targets in Google and needs some scheduled time to land

@crisbeto crisbeto changed the title fix(dialog): dialog content not being read out by screen readers fix(material/dialog): dialog content not being read out by screen readers Dec 26, 2020
…ders

Currently we focus the first focusable element inside a dialog as per the accessibility
recommendations, however moving focus to the first item causes some screen readers
not to read out the rest of the dialog content. These changes switch to focusing the
dialog container by default which allows screen readers to read out everything. If
users press tab, they'll land on the first tabbable element anyways. The old behavior
can still be opted into via the `autoFocus` option.

Fixes angular#10591.
@crisbeto crisbeto force-pushed the 10591/dialog-content-screen-readers branch from 5f5be59 to 8546297 Compare December 26, 2020 14:00
@DmitryEfimenko
Copy link

I've been experiencing this issue in the application I'm working on, which led me to diving deeper into it. Based on my research, I don't think that the proposed fix is the best way forward.

Please have a look at the example of accessible dialog here, which has autofocusing functionality as well. I've tested it with NVDA. The screen reader announces both, the title and the description while having the first focusable element autofocused. This is due to the fact that the element with attribute role="alert" also has attributes aria-labelledby pointing at the title and aria-describedby pointing at the description.

I've attempted to apply this fix in my app, but I'm still not getting the title or description read out. I believe this is due to the fact that focus is assigned to the dialog container first and then immediately assigned to the first focusable element. Instead, it needs to be assigned to the first focusable element immediately. This is a running theory - not something I have confirmed. However, given the working example of a dialog above, I think we should be able to fix material dialog to read out all content while keeping the default value of autoFocus to true

@crisbeto
Copy link
Member Author

This fix was superseded by #23085.

@crisbeto crisbeto closed this Dec 28, 2021
@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 Jan 28, 2022
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 P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

a11y: mat-dialog description not read by NVDA in Chrome
7 participants