angular / angular/components

bug(MatDialog): Immediate navigation to a route after MatDialog is closed, crashes the Angular App / browser

未关闭
#28,066 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
cannot reproduce
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Is this a regression?

- [X] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

I am loading a dialog to ask user to verify email. On the dialog there's also a link which can be clicked in case user wants to update their email. As soon as the user click Update Email link and dialog is closed the browser tab crashes and Chrome display `Aw, Snap! error`

### Reproduction

I am loading a dialog to ask user to verify email. On the dialog there's also a link which can be clicked in case user wants to update their email.

```
import('./verify-email-dialog.component').then((c) => {
let config = new MatDialogConfig();
config.viewContainerRef = this.viewContainerRef;
config.disableClose = true;
config.panelClass = "header-pattern";

this.dialogRef = this.dialog.open(c.VerifyEmailDialog, config);
this.dialogRef.afterClosed().subscribe(result => {
if (result == 'updateEmail') {
this._router.navigate(['/account/manage/profile']);
return;
}

if (result === true) {
this.emailConfirmed = true;
}
});
});
```

Below is how I am closing dialog in case user click Update Email link in `VerifyEmailDialog`:

```
updateEmail() {
this.dialogRef.close('updateEmail');
}
```

As soon as the user click Update Email link and dialog is closed the browser tab crashes and Chrome display `Aw, Snap! error`

### Expected Behavior

it should work smoothly

### Actual Behavior

The browser crashes

### Environment

Angular CLI: 17.0.0-rc.4
Node: 18.18.2
Package Manager: npm 9.8.1
OS: win32 x64

Angular: 17.0.0-rc.3
... animations, cdk, common, compiler, compiler-cli, core, forms
... google-maps, material, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1700.0-rc.4
@angular-devkit/build-angular 17.0.0-rc.4
@angular-devkit/core 17.0.0-rc.4
@angular-devkit/schematics 17.0.0-rc.4
@angular/cli 17.0.0-rc.4
@angular/fire 16.0.0
@angular/pwa 17.0.0-rc.4
@schematics/angular 17.0.0-rc.4
rxjs 7.8.1
typescript 5.2.2
zone.js 0.14.0

贡献指南

打开贡献指南

调研方向

从复现中展示的 MatDialog 流程开始:dialog.open、afterClosed、dialogRef.close('updateEmail'),以及后续的 router.navigate 调用。在 Angular 17 环境中复现立即导航序列;当关闭对话框并导航到 /account/manage/profile 不再导致浏览器崩溃时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。