Skip to content

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

Open
@Harpush

Description

@Harpush

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.

Activity

added
featureThis issue represents a new feature or feature request rather than a bug or bug fix
needs triageThis issue needs to be triaged by the team
on Sep 6, 2022
crisbeto

crisbeto commented on Oct 17, 2022

@crisbeto
Member

We have the MAT_DIALOG_DEFAULT_OPTIONS injection token that allows you to configure the defaults for the dialog. Is this what you're looking for?

Harpush

Harpush commented on Oct 17, 2022

@Harpush
Author

We have the MAT_DIALOG_DEFAULT_OPTIONS injection token that allows you to configure the defaults for the dialog. Is this what you're looking for?

Unfortunately no... The idea is per component basis. So the component author can specify it. The injection token you mentioned can only be specified from outside the dialog as far as I know. The main idea is the component author should know best what fits the dialog (in most cases) and should provide a default on the component itself and not from outside.

Harpush

Harpush commented on Jan 15, 2023

@Harpush
Author

@crisbeto Any news concerning this?

added
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
and removed
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
needs triageThis issue needs to be triaged by the team
on May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/dialogfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @crisbeto@andrewseguin@Harpush

        Issue actions

          feat(MatDIalog): Allow specifying MatDialogConfig as part of the dialog component · Issue #25582 · angular/components