@@ -31,6 +31,7 @@ import {
3131 inject ,
3232 inputBinding ,
3333} from '@angular/core' ;
34+ import { DialogRef } from '@angular/cdk/dialog' ;
3435import { ComponentFixture , TestBed } from '@angular/core/testing' ;
3536import { By } from '@angular/platform-browser' ;
3637import { Subject } from 'rxjs' ;
@@ -873,6 +874,14 @@ describe('MatDialog', () => {
873874 expect ( pane . classList ) . not . toContain ( 'custom-class-one' , 'Expected class to be removed' ) ;
874875 } ) ;
875876
877+ it ( 'should not inject the CDK dialog ref into the child component' , ( ) => {
878+ const dialogRef = dialog . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
879+ viewContainerFixture . detectChanges ( ) ;
880+
881+ expect ( dialogRef . componentInstance . cdkDialogRef ) . toBe ( null ) ;
882+ expect ( dialogRef . componentInstance . dialogRef ) . toBeTruthy ( ) ;
883+ } ) ;
884+
876885 describe ( 'disableClose option' , ( ) => {
877886 it ( 'should prevent closing via clicks on the backdrop' , async ( ) => {
878887 dialog . open ( PizzaMsg , { disableClose : true , viewContainerRef : testViewContainerRef } ) ;
@@ -2372,6 +2381,7 @@ class PizzaMsg {
23722381 dialogRef = inject < MatDialogRef < PizzaMsg > > ( MatDialogRef ) ;
23732382 dialogInjector = inject ( Injector ) ;
23742383 directionality = inject ( Directionality ) ;
2384+ cdkDialogRef = inject ( DialogRef , { optional : true } ) ;
23752385}
23762386
23772387@Component ( {
0 commit comments