question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a beforeClose method for MdDialog

See original GitHub issue

Feature Request

What is the expected behavior?

When the user is about to close a MdDialog window (via Esc key, clickout or close button), for example an edit dialog, it would be nice to be able to have some method to prevent the window from closing to avoid unsaved changes for example.

What is the use-case or motivation for changing an existing behavior?

Since the MdDialog already listens to Esc key events, clickout and has the close() method that is used in the action buttons, it would be much easier to have a method like afterClosed that is called just before the closing event is going to occur, so we could prevent it from happening just returning true or false in a callback function. This way we don’t have to overwrite those event listeners.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
davidmorissettecommented, Jun 9, 2017

In my opinion beforeClose and disableClose serve two different purposes. Imagine a scenario where you want to prompt a user before discarding the changes (no matter how the cancellation happened); then using beforeClose would allow us to cancel closing the dialog. However, disableClose would completely remove the ability for the user to close the dialog (via cancellation) which is not what is expected.

3reactions
mtycholazcommented, Jul 26, 2017

Much needed! We have a use-case where we want to save data if the user cancels the dialog (via clicking on backdrop or hitting the Esc key). Where the problem comes in, is if there’s a server error, we want to keep the modal up still to display the message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add 'beforeClose' Observable to MdDialogRef #5209 - GitHub
Being able to start processing instantly when a user selects an option in an MdDialog. What is the current behavior? An 'afterClose' Observable ......
Read more >
mdDialog: catch the onClose event - angularjs - Stack Overflow
The first is called when the Dialog is already closed. This is due to the requirements unacceptable (there is an iFrame that needs...
Read more >
Services > $mdDialog - AngularJS Material
$mdDialog opens a dialog over the app to inform users about critical information or require them to make decisions. There are two approaches...
Read more >
Angular Material Dialog: A Complete Example
In this post, we are going to go through a complete example of how to build a custom dialog using the Angular Material...
Read more >
Dialog | Angular Material
The MatDialog service can be used to open modal dialogs with Material Design ... A dialog is opened by calling the open method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found