-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
md-dialog Before close functionality? #6369
Comments
Duplicate of #4647. For your use case specifically, see #4647 (comment) and #3460. |
@willshowell so comment mentioned doesn't match the next issue. Will the PR mentioned be a part of one of the next releases? |
So in order to cancel the close (e.g. to show a message when the form needs to be saved or whatever), you would have to pass Those two streams are not yet available and that's what #3460 is all about (particularly the last ~5-6 comments). However, once #6330 is completed, that will be easy work to make them part of the dialog's public api. In summary, I doubt they'll be in the next release, but probably in the following 1-2. |
Duplicate of #4647 |
@willshowell I am new to Angular but I was wondering if you could provide a fiddle showing how you would do the following: "So in order to cancel the close (e.g. to show a message when the form needs to be saved or whatever), you would have to pass disableClose to the dialog. Then you would be able to subscribe to backdropClick and escapeKeyEvent streams to show the message or close the dialog on your own." |
@dfmmalaw this won't be available until #6682 lands. It could look like this: const dialogRef = dialog.open(MyDialogComponent, {disableClose: true});
const escapeEvents = dialogRef.keydownEvents().filter(e => e.key === 'Escape');
Observable.merge(escapeEvents, dialogRef.backdropClick())
.map(() => confirm('Are you sure you want to cancel?'))
.filter(confirmed => !!confirmed)
.first()
.subscribe(() => dialog.close());
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Feature?
What is the expected behavior?
When user clicks on
backdrop
oresc
the dialog closes. It would be nice to give the user the option to intercept this close method and prevent default behavior based on some condition.What is the use-case or motivation for changing an existing behavior?
For example if Dialog contains a form, to be able to disable close or display a message (or whatever function he/she wants to run) and prevent the modal from closing.
The text was updated successfully, but these errors were encountered: