angular / angular/components

feat(MatDIalog): Allow specifying MatDialogConfig as part of the dialog component

Offen
#25,582 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
area: material/dialog feature P3
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Feature Description

Currently if there is a dialog which is meant to be used with a specific width, height, autoFocus, disableClose, etc... each and every code that opens that dialog need to specify those values. Even if extracted to a const you still need to remember to pass it.

What I wish to have is the ability to specify on the dialog component itself those configuration options or at least some of them that make sense. Allowing to actually "declare" to the one using - If you pass nothing in the `open` function config - this is the recommended and default config for this specific dialog. If you do pass a config object it overrides the recommended one.

### Use Case

When having a dialog that needs for example to have `autoFocus` as false always as it handles it inside - everyone using that dialog has to remember to declare this specific config when opening otherwise the dialog won't work as expected. Even if it was extracted to a const - the one opening the dialog still needs to know that const exists and remember to pass it.
The suggestion allows the dialog creator to specify the default config.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, die APIs von MatDialog und MatDialogConfig sowie die bestehende Diskussion zum Issue zu prüfen. Lege fest, wie eine Dialogkomponente eine Standardkonfiguration deklarieren würde und wie beim Aufruf von open bereitgestellte Werte diese überschreiben würden; abgeschlossen ist die Aufgabe, wenn das angeforderte Verhalten der Standardkonfiguration spezifiziert und durch geeignete Tests abgedeckt ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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