Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Geschlossen
#34,005 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
angular, typescript
Bereich
frontend

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
3 T. 7 Std.
Gemergte PRs (30 T.)
59

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/components

Alle Issues in angular/components

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.