6
6
* found in the LICENSE file at https://angular.dev/license
7
7
*/
8
8
9
- import { ComponentType , Overlay , ScrollStrategy } from '@angular/cdk/overlay' ;
9
+ import {
10
+ ComponentType ,
11
+ createBlockScrollStrategy ,
12
+ createGlobalPositionStrategy ,
13
+ ScrollStrategy ,
14
+ } from '@angular/cdk/overlay' ;
10
15
import {
11
16
ComponentRef ,
12
17
Injectable ,
13
18
InjectionToken ,
19
+ Injector ,
14
20
OnDestroy ,
15
21
TemplateRef ,
16
22
Type ,
@@ -39,8 +45,8 @@ export const MAT_DIALOG_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrateg
39
45
{
40
46
providedIn : 'root' ,
41
47
factory : ( ) => {
42
- const overlay = inject ( Overlay ) ;
43
- return ( ) => overlay . scrollStrategies . block ( ) ;
48
+ const injector = inject ( Injector ) ;
49
+ return ( ) => createBlockScrollStrategy ( injector ) ;
44
50
} ,
45
51
} ,
46
52
) ;
@@ -50,11 +56,11 @@ export const MAT_DIALOG_SCROLL_STRATEGY = new InjectionToken<() => ScrollStrateg
50
56
*/
51
57
@Injectable ( { providedIn : 'root' } )
52
58
export class MatDialog implements OnDestroy {
53
- private _overlay = inject ( Overlay ) ;
54
59
private _defaultOptions = inject < MatDialogConfig > ( MAT_DIALOG_DEFAULT_OPTIONS , { optional : true } ) ;
55
60
private _scrollStrategy = inject ( MAT_DIALOG_SCROLL_STRATEGY ) ;
56
61
private _parentDialog = inject ( MatDialog , { optional : true , skipSelf : true } ) ;
57
62
private _idGenerator = inject ( _IdGenerator ) ;
63
+ private _injector = inject ( Injector ) ;
58
64
protected _dialog = inject ( Dialog ) ;
59
65
private _animationsDisabled = _animationsDisabled ( ) ;
60
66
@@ -138,7 +144,9 @@ export class MatDialog implements OnDestroy {
138
144
139
145
const cdkRef = this . _dialog . open < R , D , T > ( componentOrTemplateRef , {
140
146
...config ,
141
- positionStrategy : this . _overlay . position ( ) . global ( ) . centerHorizontally ( ) . centerVertically ( ) ,
147
+ positionStrategy : createGlobalPositionStrategy ( this . _injector )
148
+ . centerHorizontally ( )
149
+ . centerVertically ( ) ,
142
150
// Disable closing since we need to sync it up to the animation ourselves.
143
151
disableClose : true ,
144
152
// Closing is tied to our animation so the close predicate has to be implemented separately.
0 commit comments