@@ -11,8 +11,10 @@ import {
11
11
ChangeDetectionStrategy ,
12
12
Component ,
13
13
NgModule ,
14
+ NgZone ,
14
15
OnDestroy ,
15
16
ViewEncapsulation ,
17
+ inject ,
16
18
} from '@angular/core' ;
17
19
import { MatDialog , MatDialogConfig , MatDialogModule , MatDialogRef } from '@angular/material/dialog' ;
18
20
import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
@@ -41,6 +43,8 @@ export class MatTestDialogOpener<T = unknown, R = unknown> implements OnDestroy
41
43
42
44
private readonly _afterClosedSubscription : Subscription ;
43
45
46
+ private readonly _ngZone = inject ( NgZone ) ;
47
+
44
48
/** Static method that prepares this class to open the provided component. */
45
49
static withComponent < T = unknown , R = unknown > (
46
50
component : ComponentType < T > ,
@@ -56,9 +60,11 @@ export class MatTestDialogOpener<T = unknown, R = unknown> implements OnDestroy
56
60
throw new Error ( `MatTestDialogOpener does not have a component provided.` ) ;
57
61
}
58
62
59
- this . dialogRef = this . dialog . open < T , R > (
60
- MatTestDialogOpener . component as ComponentType < T > ,
61
- MatTestDialogOpener . config || { } ,
63
+ this . dialogRef = this . _ngZone . run ( ( ) =>
64
+ this . dialog . open < T , R > (
65
+ MatTestDialogOpener . component as ComponentType < T > ,
66
+ MatTestDialogOpener . config || { } ,
67
+ ) ,
62
68
) ;
63
69
this . _afterClosedSubscription = this . dialogRef . afterClosed ( ) . subscribe ( result => {
64
70
this . closedResult = result ;
0 commit comments