New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
philmtd opened this Issue Jan 10, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@philmtd
Copy link

philmtd commented Jan 10, 2019

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.

philmtd added a commit to philmtd/material2 that referenced this issue Jan 13, 2019

feat(dialog): Add an option to provide a default dialog result
Provide the option to use a default value as the dialog result when close() gets called without parameters. This can be useful when a dialog is expected to return a result when it gets closed via escape or a backdrop click.

Closes angular#14780.

philmtd added a commit to philmtd/material2 that referenced this issue Jan 13, 2019

feat(dialog): Add an option to provide a default dialog result
Provide the option to use a default value as the dialog result when close() gets called without parameters. This can be useful when a dialog is expected to return a result when it gets closed via escape or a backdrop click.

Closes angular#14780.

philmtd added a commit to philmtd/material2 that referenced this issue Jan 13, 2019

feat(dialog): Add an option to provide a default dialog result
Provide the option to use a default value as the dialog result when close() gets called without parameters. This can be useful when a dialog is expected to return a result when it gets closed via escape or a backdrop click.

Closes angular#14780.

philmtd added a commit to philmtd/material2 that referenced this issue Jan 13, 2019

feat(dialog): Add an option to provide a default dialog result
Provide the option to use a default value as the dialog result when close() gets called without parameters. This can be useful when a dialog is expected to return a result when it gets closed via escape or a backdrop click.

Closes angular#14780.
@philmtd

This comment has been minimized.

Copy link

philmtd commented Jan 13, 2019

I created #14812 which makes this possible.

philmtd added a commit to philmtd/material2 that referenced this issue Jan 15, 2019

feat(dialog): Add an option to provide a default dialog result
Provide the option to use a default value as the dialog result when close() gets called without parameters. This can be useful when a dialog is expected to return a result when it gets closed via escape or a backdrop click.

Closes angular#14780.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment