bug(MatDialog): When opening multiple dialogs in a short amount of time, some of them do not open
See original GitHub issueIs this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
12.2.0
Description
When opening multiple dialogs in a short amount of time, some of them do not open
Reproduction
The bug can be noticed with the example below, when clicking the “Open Fast” button.
import { Component, TemplateRef, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
@Component({
selector: 'app-root',
template: `
<button (click)="openFast()">Open Fast</button>
<button (click)="openSlow()">Open Slow</button>
<ng-template let-data #template>
{{data.message}}
<button mat-dialog-close>close</button>
</ng-template>
`
})
export class AppComponent {
@ViewChild("template") template?: TemplateRef<any>;
constructor(private matDialog: MatDialog){}
openFast(){
this.open('1');
setTimeout(() => this.open('2'), 1);
setTimeout(() => this.open('3'), 50);
setTimeout(() => this.open('4'), 100);
setTimeout(() => this.open('5'), 150);
setTimeout(() => this.open('6'), 200);
}
openSlow(){
this.open('1');
setTimeout(() => this.open('2'), 300);
setTimeout(() => this.open('3'), 600);
setTimeout(() => this.open('4'), 900);
setTimeout(() => this.open('5'), 1200);
setTimeout(() => this.open('6'), 1500);
}
private open(message: string){
this.matDialog.open(this.template!, {
disableClose: true,
data: { message }
});
}
}
Expected Behavior
“Open fast” button should open 6 dialogs, just like the “Open slow” button.
Actual Behavior
The “Open fast” button opens only 2 dialogs. On most attempts it opens (1) and (5), but in some cases (1) and (6) are open.
Environment
- Angular: 13.0.0
- CDK/Material: 13.0.0
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:37 (16 by maintainers)
Top Results From Across the Web
Angular Material: mat-dialog opens multiple dialog boxes ...
My idea was to display a list of all players per team, and to be able to click on a player's name and...
Read more >How to Resolve multiple concurrent Angular Material 2 Modal ...
We want both the dialogs to remain open at the same time. ... dialog “update form” closes as soon the second dialog “Information”...
Read more >Dialogs – Material Design 3
Dialogs can require an action, communicate information, or help users accomplish a task. There are two types of dialogs: basic and full-screen.
Read more >Angular Dynamic Components: Building a Dialog System
In this tutorial, you will learn what dynamic components are and how they work in angular. You will do so by creating a...
Read more >How to create a reusable Modal Dialog component in Angular 8
This component can be opened from any parent component, ... This way, no matter how many mat-dialog-container s the application has, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PR https://github.com/angular/components/pull/24121 has been tested and reviewed. It should land shortly and fix this.
This fix is included in 13.2.6 and 14.0.0-next.6.