66 * found in the LICENSE file at https://angular.dev/license
77 */
88
9- import { ComponentType , Overlay , ScrollStrategy } from '@angular/cdk/overlay' ;
9+ import {
10+ ComponentType ,
11+ createBlockScrollStrategy ,
12+ createGlobalPositionStrategy ,
13+ ScrollStrategy ,
14+ } from '@angular/cdk/overlay' ;
1015import {
1116 ComponentRef ,
1217 Injectable ,
1318 InjectionToken ,
19+ Injector ,
1420 OnDestroy ,
1521 TemplateRef ,
1622 Type ,
@@ -39,8 +45,8 @@ export const MAT_DIALOG_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrateg
3945 {
4046 providedIn : 'root' ,
4147 factory : ( ) => {
42- const overlay = inject ( Overlay ) ;
43- return ( ) => overlay . scrollStrategies . block ( ) ;
48+ const injector = inject ( Injector ) ;
49+ return ( ) => createBlockScrollStrategy ( injector ) ;
4450 } ,
4551 } ,
4652) ;
@@ -50,11 +56,11 @@ export const MAT_DIALOG_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrateg
5056 */
5157@Injectable ( { providedIn : 'root' } )
5258export class MatDialog implements OnDestroy {
53- private _overlay = inject ( Overlay ) ;
5459 private _defaultOptions = inject < MatDialogConfig > ( MAT_DIALOG_DEFAULT_OPTIONS , { optional : true } ) ;
5560 private _scrollStrategy = inject ( MAT_DIALOG_SCROLL_STRATEGY ) ;
5661 private _parentDialog = inject ( MatDialog , { optional : true , skipSelf : true } ) ;
5762 private _idGenerator = inject ( _IdGenerator ) ;
63+ private _injector = inject ( Injector ) ;
5864 protected _dialog = inject ( Dialog ) ;
5965 private _animationsDisabled = _animationsDisabled ( ) ;
6066
@@ -138,7 +144,9 @@ export class MatDialog implements OnDestroy {
138144
139145 const cdkRef = this . _dialog . open < R , D , T > ( componentOrTemplateRef , {
140146 ...config ,
141- positionStrategy : this . _overlay . position ( ) . global ( ) . centerHorizontally ( ) . centerVertically ( ) ,
147+ positionStrategy : createGlobalPositionStrategy ( this . _injector )
148+ . centerHorizontally ( )
149+ . centerVertically ( ) ,
142150 // Disable closing since we need to sync it up to the animation ourselves.
143151 disableClose : true ,
144152 // Closing is tied to our animation so the close predicate has to be implemented separately.
0 commit comments