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

Decouple backdrop click and ESC press on mat-dialog #10190

Closed
salemdar opened this issue Feb 28, 2018 · 5 comments
Closed

Decouple backdrop click and ESC press on mat-dialog #10190

salemdar opened this issue Feb 28, 2018 · 5 comments

Comments

@salemdar
Copy link

salemdar commented Feb 28, 2018

Feature request:

Both ESC and backdrop click closes an active dialog. This can be disabled at the moment, but only all together. These two behaviours should be decoupled.

What is the expected behavior?

MatDialogConfig should have 2 extra properties:

// ...
disableCloseOnEscape: boolean,
disableCloseOnBackdropClick: boolean

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

So we can disable closing on backdrop click, but keep close on ESC press. It would be very helpful for inaccurate mouse users :).

@salemdar salemdar changed the title Decouple backdrop click and <kbd>ESC</kbd> press on mat-dialog Decouple backdrop click and ESC press on mat-dialog Feb 28, 2018
@willshowell
Copy link
Contributor

The suggested approach for this is to set disableClose and then use keydownEvents or backdropClick to re-enable the desired behavior.

See #3460 and linked threads for more context.

@salemdar
Copy link
Author

salemdar commented Feb 28, 2018

@willshowell thanks for your comment. I am aware that there are possible workarounds. For example, I wrote something like this:

const dialogRef = this.dialog.open(MyDialogComponent, {
  disableClose: true
});
dialogRef.keydownEvents()
  .filter((e: KeyboardEvent) => e.code === 'Escape')
  .take(1)
  .subscribe(() => dialogRef.close());

But wouldn't it be nice to have it out of box? I believe it could be useful for many people.

@willshowell
Copy link
Contributor

@salemdar the team (at least in the past) has held pretty strong to this. See #3460 (comment) for a better explanation than I can give.

@jelbourn
Copy link
Member

jelbourn commented Mar 1, 2018

Yep, as per Will's comment, we don't really want to decouple these behaviors.

@jelbourn jelbourn closed this as completed Mar 1, 2018
@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants