Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Feature (MatDialog): Add an option to prevent duplicate dialogs

Fermée
#34,005 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

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

area: material/dialog feature gemini-triaged needs triage
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

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de angular/components

Toutes les issues de angular/components

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.