Feature (MatDialog): Add an option to prevent duplicate dialogs
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- angular, typescript
- Domaine
- frontend
Piste de recherche
Start by reading the MatDialog API and its existing openDialogs and getDialogById() behavior. The proposal leaves key behavior undecided, including whether to return the existing reference or ignore the request, and how duplicate detection should be customized. Done criteria would need maintainers to settle those choices and define how component type matching works.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Feature Description
Currently, Angular Material’s MatDialog allows the same component to be opened multiple times, resulting in multiple instances of the same dialog being displayed simultaneously.
In some applications, this behavior is undesirable. For example, repeated user interactions or multiple event emissions can accidentally open the same dialog more than once.
Developers must currently implement their own duplicate detection logic using MatDialog.openDialogs or MatDialog.getDialogById() before calling MatDialog.open().
Proposed solution
It would be useful to have a built-in option in MatDialogConfig to prevent duplicate instances of the same component from being opened.
For example:
this.dialog.open(MyDialogComponent, {
preventDuplicates: true,
});
When this option is enabled, attempting to open a component that already has an open dialog could either:
- Return the existing MatDialogRef without creating another instance.
- Ignore the new request and keep the existing dialog open.
The exact behavior could be determined by the maintainers.
Ideally, duplicate detection would be scoped to the component type, with an option to customize the behavior if needed.
Benefits
- Avoids accidentally opening multiple instances of the same dialog.
- Reduces repetitive boilerplate across applications.
- Provides a consistent, framework-level solution.
- Keeps applications simpler and less error-prone.
Alternatives considered
Currently, developers can manually inspect openDialogs or use getDialogById() before opening a dialog. However, this requires additional application-level logic and does not provide a straightforward, reusable option for this common use case.
Would this feature be a good fit for Angular Material’s MatDialog API? I’d be happy to contribute a PR if the maintainers consider this approach appropriate.
Use Case
No response
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 3 j 7 h
- PR mergées (30 j)
- 59
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de angular/components
-
bug(aria/accordion): Enter/Space inside a panel toggles the accordion instead of activating the focused elementPeut-être pris @agarwalU001 l’a pris il y a 1 jour. Ouvertearea: aria/accordion gemini-triaged needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
angular/components#34011 ·
Les mainteneurs répondent en général sous 1 jour
-
bug(aria/combobox): keys pressed back to back are lost; only the last one reaches the popupPeut-être pris @drakeo338 l’a pris il y a 7 jours. Ouvertearea: aria/combobox gemini-triaged
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
angular/components#33973 ·
Les mainteneurs répondent en général sous 1 jour
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Peut-être pris @lekhmanrus l’a pris il y a 19 jours. Ouvertearea: material/sort P3
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
angular/components#33933 ·
Les mainteneurs répondent en général sous 1 jour
-
bug(mat-date-picker): month shown twice in date pickerPeut-être pris @PreethiPantangi l’a pris il y a 36 jours. Ouvertearea: material/datepicker P4
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
angular/components#33763 · 2 commentaires · 3 réactions ·
Les mainteneurs répondent en général sous 1 jour
-
Bug in table.scss footer cell height: unset instead of footer row height unsetPeut-être pris @minwookshin l’a pris il y a 23 jours. Ouvertearea: material/table P4
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
angular/components#33709 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de angular/components
Issues similaires
-
Add: ON Phim Viet SDOuvertecheck:passed streams:add
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 1 jour
-
Subagent progress token count ignores usage.iterations and swings on multi-iteration responsesOuvertearea:agents area:cost bug platform:macos
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
anthropics/claude-code#105375 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
galaxyproject/loom#616 ·
Les mainteneurs répondent en général sous 1 jour
-
e2e-failure ready-to-code
Difficulté 2/5 1-3 heures Accessibilité débutants 79/100
redhat-developer/rhdh-plugin-export-overlays#4580 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour