Feature (MatDialog): Add an option to prevent duplicate dialogs
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
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
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus angular/components
-
bug(aria/accordion): Enter/Space inside a panel toggles the accordion instead of activating the focused elementEvtl. vergeben @agarwalU001 hat das vor 1 Tag übernommen. Offenarea: aria/accordion gemini-triaged needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
angular/components#34011 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug(aria/combobox): keys pressed back to back are lost; only the last one reaches the popupEvtl. vergeben @drakeo338 hat das vor 7 Tagen übernommen. Offenarea: aria/combobox gemini-triaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
angular/components#33973 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Evtl. vergeben @lekhmanrus hat das vor 18 Tagen übernommen. Offenarea: material/sort P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
angular/components#33933 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug(mat-date-picker): month shown twice in date pickerEvtl. vergeben @PreethiPantangi hat das vor 36 Tagen übernommen. Offenarea: material/datepicker P4
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
angular/components#33763 · 2 Kommentare · 3 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug in table.scss footer cell height: unset instead of footer row height unsetEvtl. vergeben @minwookshin hat das vor 23 Tagen übernommen. Offenarea: material/table P4
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
angular/components#33709 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in angular/components
Ähnliche Issues
-
e2e-failure ready-to-code
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
redhat-developer/rhdh-plugin-export-overlays#4580 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
devdotfast/whiteboard#1415 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
area/sessions comp/desktop desktop/sessions P2 type/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
NousResearch/hermes-agent#145383 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement p2 setup
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
vercel/eve#5419 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag