Skip to content

(dialog) feature request: default result value for closing with esc or via backdrop click #14780

@philmtd

Description

@philmtd

Please describe the feature you would like to request.

Current behaviour: When a dialog is closed with esc or via backdrop click the provided result is undefined.
Desired behaviour: Allow to set a default result for these situations. I'd see several possible ways of doing this, for example:

  1. using the MatDialogRef and a to be created method (e.g. setDefaultResult(...)) to be able to set this value comfortably from within the dialog.
  2. using the MatDialogConfig to be able to set the value from the code opening the dialog

What is the use-case or motivation for this proposal?

We have some generic dialogs which also provide a "cancel" button that returns specific data. Currently everywhere the dialog is opened, we need to make a check whether the result is undefined or not. Providing a default value for those cases would definitely be better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: 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

    Issue actions