8
8
9
9
import { LiveAnnouncer } from '@angular/cdk/a11y' ;
10
10
import { 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' ;
12
18
import {
13
19
ComponentRef ,
14
20
EmbeddedViewRef ,
@@ -50,7 +56,6 @@ export const MAT_SNACK_BAR_DEFAULT_OPTIONS = new InjectionToken<MatSnackBarConfi
50
56
*/
51
57
@Injectable ( { providedIn : 'root' } )
52
58
export class MatSnackBar implements OnDestroy {
53
- private _overlay = inject ( Overlay ) ;
54
59
private _live = inject ( LiveAnnouncer ) ;
55
60
private _injector = inject ( Injector ) ;
56
61
private _breakpointObserver = inject ( BreakpointObserver ) ;
@@ -274,7 +279,7 @@ export class MatSnackBar implements OnDestroy {
274
279
const overlayConfig = new OverlayConfig ( ) ;
275
280
overlayConfig . direction = config . direction ;
276
281
277
- let positionStrategy = this . _overlay . position ( ) . global ( ) ;
282
+ const positionStrategy = createGlobalPositionStrategy ( this . _injector ) ;
278
283
// Set horizontal position.
279
284
const isRtl = config . direction === 'rtl' ;
280
285
const isLeft =
@@ -298,7 +303,7 @@ export class MatSnackBar implements OnDestroy {
298
303
299
304
overlayConfig . positionStrategy = positionStrategy ;
300
305
overlayConfig . disableAnimations = this . _animationsDisabled ;
301
- return this . _overlay . create ( overlayConfig ) ;
306
+ return createOverlayRef ( this . _injector , overlayConfig ) ;
302
307
}
303
308
304
309
/**
0 commit comments