When clicking an element with the routerLink directive, the navigation should close the dialog and make the backdrop disappear
The dialog closes but the backdrop stays open.
Doesn't work even with closeOnNavigation: true or with applying mat-dialog-close to the element that has the routerLink directive
Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV
Have an element with a routerLink directive inside a mat dialog template and click on it to navigate.
Angular Core: 7.2.5
Angular Material: 7.3.2
Can you provide a reproduction in StackBlitz. This will help us to investigate the issue you are seeing.
I ran into this and found that the issue was that the dialogRef wasn't triggering ngOnDestroy when it moved to the new route.
Found something that seems to work - I wrapped the routerLink in an tag
From within the dialog:
<button mat-button [routerLink]="'newRoute'">GO SOMEWHERE</button>
To
<a [routerLink]="'newRoute'"><button mat-button >GO SOMEWHERE</button></a>
Early finding is that it seems to trigger a cleanup of the old components and creation of a new route tree - will add more if I see anything different.
reproduce: https://angular-h4uz66.stackblitz.io
Any news on this?
My current workaround:
private _dialogRef: MatDialogRef<ModalComponent> = null;
openDialog() {
this._dialogRef = this._dialog.open(ModalComponent);
this._dialogRef.afterClosed().subscribe(() => this._dialogRef = null);
}
ngOnDestroy() {
if (this._dialogRef) {
this._dialogRef.close();
}
}
Closing because this issue has been inactive for 2 weeks or more after follow up was requested.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Any news on this?
My current workaround: