angular / angular/components

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

Open
#25,582 3 comments 1 reaction 0 assignees View on GitHub
area: material/dialog feature P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### 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.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the MatDialog and MatDialogConfig APIs and the existing issue discussion. Define how a dialog component would declare default configuration and how values supplied to open would override it; done means the requested default-config behavior is specified and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.