Feature (MatDialog): Add an option to prevent duplicate dialogs
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
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
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di angular/components
-
bug(aria/accordion): Enter/Space inside a panel toggles the accordion instead of activating the focused elementForse già presa @agarwalU001 l’ha presa oggi. Apertaarea: aria/accordion gemini-triaged needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
angular/components#34011 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(aria/combobox): keys pressed back to back are lost; only the last one reaches the popupForse già presa @drakeo338 l’ha presa 6 giorni fa. Apertaarea: aria/combobox gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
angular/components#33973 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(material/sort): hover hint arrow on an unsorted header shows the active sort direction, not the resulting direction after click.Forse già presa @lekhmanrus l’ha presa 18 giorni fa. Apertaarea: material/sort P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
angular/components#33933 ·
I maintainer di solito rispondono entro 1 giorno
-
bug(mat-date-picker): month shown twice in date pickerForse già presa @PreethiPantangi l’ha presa 35 giorni fa. Apertaarea: material/datepicker P4
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
angular/components#33763 · 2 commenti · 3 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Bug in table.scss footer cell height: unset instead of footer row height unsetForse già presa @minwookshin l’ha presa 22 giorni fa. Apertaarea: material/table P4
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
angular/components#33709 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di angular/components
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
grafana/profiles-drilldown#1212 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
grafana/traces-drilldown#980 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
openremote/openremote#3487 · 1 commento ·
-
triage:needs-human
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
garrytan/gbrain#7635 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
coollabsio/jean#867 ·
I maintainer di solito rispondono entro 1 giorno