File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -186,18 +186,16 @@ describe('MatSnackBar', () => {
186186 } ) ) ;
187187
188188
189- it ( 'should default to the passed message for the announcement message' , fakeAsync ( ( ) => {
189+ it ( 'should clear the announcement message if it is the same as main message' , fakeAsync ( ( ) => {
190190 spyOn ( liveAnnouncer , 'announce' ) ;
191191
192- snackBar . open ( simpleMessage ) ;
192+ snackBar . open ( simpleMessage , undefined , { announcementMessage : simpleMessage } ) ;
193193 viewContainerFixture . detectChanges ( ) ;
194194
195195 expect ( overlayContainerElement . childElementCount )
196196 . toBe ( 1 , 'Expected the overlay with the default announcement message to be added' ) ;
197197
198- // Expect the live announcer to have been called with the display message and some
199- // string for the politeness. We do not want to test for the default politeness here.
200- expect ( liveAnnouncer . announce ) . toHaveBeenCalledWith ( simpleMessage , jasmine . any ( String ) ) ;
198+ expect ( liveAnnouncer . announce ) . not . toHaveBeenCalled ( ) ;
201199 } ) ) ;
202200
203201 it ( 'should be able to specify a custom announcement message' , fakeAsync ( ( ) => {
Original file line number Diff line number Diff line change @@ -114,8 +114,10 @@ export class MatSnackBar implements OnDestroy {
114114 // override the data to pass in our own message and action.
115115 _config . data = { message, action} ;
116116
117- if ( ! _config . announcementMessage ) {
118- _config . announcementMessage = message ;
117+ // Since the snack bar has `role="alert"`, we don't
118+ // want to announce the same message twice.
119+ if ( _config . announcementMessage === message ) {
120+ _config . announcementMessage = undefined ;
119121 }
120122
121123 return this . openFromComponent ( SimpleSnackBar , _config ) ;
You can’t perform that action at this time.
0 commit comments