mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
Revert "fix(snack-bar): announcing same message twice to screen readers" (#14494)
* Revert "build: update nodejs bazel rules (#14466)" This reverts commita3fef46a8e. * Revert "docs(form-field): native select reset values not working in examples (#14236)" This reverts commit97f52c0924. * Revert "fix(menu): allow text wrapping in menu items (#11430)" This reverts commit3661abe061. * Revert "fix(dialog,bottom-sheet): invert backdrop color on dark themes (#13065)" This reverts commitfe96f38c10. * Revert "build: replace deprecated tslint rule with compiler option (#13186)" This reverts commit5dfa45ffa4. * Revert "fix(snack-bar): announcing same message twice to screen readers (#13298)" This reverts commit3fb4b2372f.
This commit is contained in:
@@ -186,16 +186,18 @@ describe('MatSnackBar', () => {
|
||||
}));
|
||||
|
||||
|
||||
it('should clear the announcement message if it is the same as main message', fakeAsync(() => {
|
||||
it('should default to the passed message for the announcement message', fakeAsync(() => {
|
||||
spyOn(liveAnnouncer, 'announce');
|
||||
|
||||
snackBar.open(simpleMessage, undefined, {announcementMessage: simpleMessage});
|
||||
snackBar.open(simpleMessage);
|
||||
viewContainerFixture.detectChanges();
|
||||
|
||||
expect(overlayContainerElement.childElementCount)
|
||||
.toBe(1, 'Expected the overlay with the default announcement message to be added');
|
||||
|
||||
expect(liveAnnouncer.announce).not.toHaveBeenCalled();
|
||||
// Expect the live announcer to have been called with the display message and some
|
||||
// string for the politeness. We do not want to test for the default politeness here.
|
||||
expect(liveAnnouncer.announce).toHaveBeenCalledWith(simpleMessage, jasmine.any(String));
|
||||
}));
|
||||
|
||||
it('should be able to specify a custom announcement message', fakeAsync(() => {
|
||||
|
||||
@@ -114,10 +114,8 @@ export class MatSnackBar implements OnDestroy {
|
||||
// override the data to pass in our own message and action.
|
||||
_config.data = {message, action};
|
||||
|
||||
// Since the snack bar has `role="alert"`, we don't
|
||||
// want to announce the same message twice.
|
||||
if (_config.announcementMessage === message) {
|
||||
_config.announcementMessage = undefined;
|
||||
if (!_config.announcementMessage) {
|
||||
_config.announcementMessage = message;
|
||||
}
|
||||
|
||||
return this.openFromComponent(SimpleSnackBar, _config);
|
||||
|
||||
Reference in New Issue
Block a user