Is this a regression?
The previous version in which this bug was not present was
No response
Description
I lost hours trying to make DialogRef's disableClose to work, even when I have dozens of dialogs doing the same thing, disabling the easy close of the dialog when a form is dirty.
The simple fix was to not use DialogRef, because the dialog was open with MatDialog, not with CDK's Dialog.
Reproduction
StackBlitz link: https://stackblitz.com/edit/ahexqiuq?file=src%2Fexample%2Fdialog-content-example.ts
Steps to reproduce:
- Open the dialog on the test.
- The dialog can be closed with the Esc key.
- Edit the source code and enable the line
private readonly dialogRef = inject(MatDialogRef); instead of private readonly dialogRef = inject(DialogRef); - The dialog can not be closed with the Esc key.
Expected Behavior
In an ideal world injecting a more generic version of DialogRef should not be a problem, it is what someone expect from inheritance, for example using a more generic type for a variable, but as injection is not a simple type declaration, maybe it is not possible. In this case I expect an error injecting a plain CDK DialogRef in a component that was open by MatDialog. not getting a DialogRef that is not functional.
Actual Behavior
A DialogRef instance is injected without errors but that is non functional, at least the disableClose property.
Environment
- Angular: 22.1.0
- CDK/Material: 22.1.0
- Browser(s): Firefox
- Operating System (e.g. Windows, macOS, Ubuntu): Fedora Linux
Is this a regression?
The previous version in which this bug was not present was
No response
Description
I lost hours trying to make DialogRef's disableClose to work, even when I have dozens of dialogs doing the same thing, disabling the easy close of the dialog when a form is dirty.
The simple fix was to not use DialogRef, because the dialog was open with MatDialog, not with CDK's Dialog.
Reproduction
StackBlitz link: https://stackblitz.com/edit/ahexqiuq?file=src%2Fexample%2Fdialog-content-example.ts
Steps to reproduce:
private readonly dialogRef = inject(MatDialogRef);instead ofprivate readonly dialogRef = inject(DialogRef);Expected Behavior
In an ideal world injecting a more generic version of
DialogRefshould not be a problem, it is what someone expect from inheritance, for example using a more generic type for a variable, but as injection is not a simple type declaration, maybe it is not possible. In this case I expect an error injecting a plain CDKDialogRefin a component that was open byMatDialog. not getting aDialogRefthat is not functional.Actual Behavior
A
DialogRefinstance is injected without errors but that is non functional, at least thedisableCloseproperty.Environment