Skip to content
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

Add a beforeClose method for MdDialog #4647

Closed
Dunos opened this issue May 18, 2017 · 7 comments · Fixed by #6377
Closed

Add a beforeClose method for MdDialog #4647

Dunos opened this issue May 18, 2017 · 7 comments · Fixed by #6377
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions

Comments

@Dunos
Copy link

Dunos commented May 18, 2017

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.

@willshowell
Copy link
Contributor

Related #3460

@jelbourn jelbourn added the feature This issue represents a new feature or feature request rather than a bug or bug fix label May 18, 2017
@jelbourn
Copy link
Member

We did originally plan on adding a beforeClose hook, but not with the ability to cancel the close. The stance has been that, rather than canceling close, the user can disableClose and take control of closing the dialog via whatever criteria suits their application.

@Dunos
Copy link
Author

Dunos commented May 19, 2017

Well, I guess something like that could work too. Do you expect to have this functionally any time soon?

@davidmorissette
Copy link

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.

@jelbourn jelbourn added the P4 A relatively minor issue that is not relevant to core functions label Jun 20, 2017
@wulfsberg
Copy link

To pitch in here (from over in #5209), I'd also like to have the value of the user choice exposed in an observable before/on close, to get access to it without having to wait for the animation.
(This is somewhat tangential to the beforeClose method, but it seems to be tracked collectively here).

@mtycholaz
Copy link

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.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants