-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(dialog):prevent dialogs from hiding live regions #10807
fix(dialog):prevent dialogs from hiding live regions #10807
Conversation
*/ | ||
function moveLiveRegion () { | ||
angular.element($mdLiveAnnouncer._liveElement).detach(); | ||
elements.$.main.append($mdLiveAnnouncer._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.
The $mdLiveAnnouncer
is a global singleton; it does not belong to the autocomplete. With this, each autocomplete will "steal" the aria-live element when it's created. Said element will also be destroyed if whichever autocomplete stole it most recently is destroyed, breaking all subsequent announcing.
The easiest way to fix this issue is probably to have the dialog specifically ignore the aria-live element when marking everything as aria-hidden
.
7b78cc3
to
19f90bd
Compare
@jelbourn thanks for explaining, didn't know services were singletons. took your suggestion, which works as well. 🙏 👀 |
19f90bd
to
e0e638c
Compare
if (element !== children[i] && !isNodeOneOf(children[i], ['SCRIPT', 'STYLE'])) { | ||
if (element !== children[i] && | ||
!isNodeOneOf(children[i], ['SCRIPT', 'STYLE']) && | ||
!children[i].hasAttribute('aria-live')) { |
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.
Can you also add a unit test for this change?
Here's an existing test for this behavior:
material/src/components/dialog/dialog.spec.js
Line 1690 in e96293a
it('should apply aria-hidden to siblings', inject(function($mdDialog, $rootScope, $timeout) { |
You should be able to follow that to create a new test
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.
👍
change how dialogs hide background elements to avoid hiding live regions, ensuring that an autocomplete inside a dialog will not have its live region aria-hidden. Adds unit test Fixes angular#10804
e0e638c
to
7c14825
Compare
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
Edit:
change how dialogs hide background elements to avoid hiding live regions, ensuring that an autocomplete inside a dialog will not have its live region aria-hidden
Fixes #10804
Out of date:
add moveLiveRegion fn that moves an autocomplete's live region off document.body
and makes it a child of md-autocomplete. this prevents dialogs from
mistakenly hiding an autocomplete's live region
Fixes #10804