-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(dialog): hide all non-overlay content from assistive technology #9016
Conversation
@@ -67,6 +69,7 @@ export class MatDialog { | |||
private _openDialogsAtThisLevel: MatDialogRef<any>[] = []; | |||
private _afterAllClosedAtThisLevel = new Subject<void>(); | |||
private _afterOpenAtThisLevel = new Subject<MatDialogRef<any>>(); | |||
private _ariaHiddenElements = new Map<Element, string|null>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WeakMap
as a precaution against memory leaks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use a WeakMap
, because we need to be able to iterate over the elements.
src/lib/dialog/dialog.ts
Outdated
/** | ||
* Hides all of the content that isn't an overlay from assistive technology. | ||
*/ | ||
private _hideContent() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_hideNonDialogContentFromAssistiveTechnology
?
src/lib/dialog/dialog.ts
Outdated
const overlayContainer = this._overlayContainer.getContainerElement(); | ||
const siblings = overlayContainer.parentElement!.children; | ||
|
||
for (let i = 0; i < siblings.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: prefer iteration from length - 1 to zero for HTMLCollection
src/lib/dialog/dialog.ts
Outdated
let sibling = siblings[i]; | ||
|
||
if (sibling !== overlayContainer && | ||
sibling !== this._liveAnnouncer.liveElement && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking this element directly, just check that the element doesn't have aria-live
? it will accomplish the same thing without needing to change the live announcer API and also safeguards against something that does its own live announcements.
f2307ba
to
bf3bbbe
Compare
Addressed the feedback @jelbourn. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, add merge ready when ready
src/lib/dialog/dialog.ts
Outdated
/** | ||
* Hides all of the content that isn't an overlay from assistive technology. | ||
*/ | ||
private __hideNonDialogContentFromAssistiveTechnology() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra _
bf3bbbe
to
3b401c2
Compare
We are seeing a number of presubmit failures from how overlays are tested. A common pattern is to provide the {
provide: OverlayContainer,
useFactory: () => {
overlayContainerElement = document.createElement('div');
return {getContainerElement: () => overlayContainerElement};
}
} This change assumes that the overlayContainer will have a parent. Is this a check we can do and only take action if a parentElement is found? |
Hides all non-overlay content from assistive technology by applying `aria-hidden` to it. This prevents users from being able to move focus out of the dialog using the screen reader navigational shortcuts. Fixes angular#7787.
3b401c2
to
873f708
Compare
Sure, done @josephperrott. |
…ngular#9016) Hides all non-overlay content from assistive technology by applying `aria-hidden` to it. This prevents users from being able to move focus out of the dialog using the screen reader navigational shortcuts. Fixes angular#7787.
…ngular#9016) Hides all non-overlay content from assistive technology by applying `aria-hidden` to it. This prevents users from being able to move focus out of the dialog using the screen reader navigational shortcuts. Fixes angular#7787.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Hides all non-overlay content from assistive technology by applying
aria-hidden
to it. This prevents users from being able to move focus out of the dialog using the screen reader navigational shortcuts.Fixes #7787.