88
99import { LiveAnnouncer } from '@angular/cdk/a11y' ;
1010import { BreakpointObserver , Breakpoints } from '@angular/cdk/layout' ;
11- import { ComponentType , Overlay , OverlayConfig , OverlayRef } from '@angular/cdk/overlay' ;
11+ import {
12+ ComponentType ,
13+ createGlobalPositionStrategy ,
14+ createOverlayRef ,
15+ OverlayConfig ,
16+ OverlayRef ,
17+ } from '@angular/cdk/overlay' ;
1218import {
1319 ComponentRef ,
1420 EmbeddedViewRef ,
@@ -50,7 +56,6 @@ export const MAT_SNACK_BAR_DEFAULT_OPTIONS = new InjectionToken<MatSnackBarConfi
5056 */
5157@Injectable ( { providedIn : 'root' } )
5258export class MatSnackBar implements OnDestroy {
53- private _overlay = inject ( Overlay ) ;
5459 private _live = inject ( LiveAnnouncer ) ;
5560 private _injector = inject ( Injector ) ;
5661 private _breakpointObserver = inject ( BreakpointObserver ) ;
@@ -274,7 +279,7 @@ export class MatSnackBar implements OnDestroy {
274279 const overlayConfig = new OverlayConfig ( ) ;
275280 overlayConfig . direction = config . direction ;
276281
277- let positionStrategy = this . _overlay . position ( ) . global ( ) ;
282+ const positionStrategy = createGlobalPositionStrategy ( this . _injector ) ;
278283 // Set horizontal position.
279284 const isRtl = config . direction === 'rtl' ;
280285 const isLeft =
@@ -298,7 +303,7 @@ export class MatSnackBar implements OnDestroy {
298303
299304 overlayConfig . positionStrategy = positionStrategy ;
300305 overlayConfig . disableAnimations = this . _animationsDisabled ;
301- return this . _overlay . create ( overlayConfig ) ;
306+ return createOverlayRef ( this . _injector , overlayConfig ) ;
302307 }
303308
304309 /**
0 commit comments