angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.35k stars 6.74k forks source link

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

Open philmtd opened 5 years ago

philmtd commented 5 years ago

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.

angular-robot[bot] commented 2 years ago

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] commented 2 years ago

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.