Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#34,005 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
angular, typescript
Ambito
frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
3g 1h
PR unite (30g)
69

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di angular/components

Tutte le issue di angular/components

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.