Esc key dosen't close dialog
niesteszeck opened this issue · comments
add this to modal.component:
@HostListener('document:keydown', ['$event'])
onKeyDownHandler(event: KeyboardEvent) {
if (event.key === "Escape") {
this.close()
}
}
Hey @niesteszeck, do you mind submitting that as a PR and I'll have it a look tomorrow, and also you'll be marked as a contributor?
Off the top of my head it looks OK but incomplete. We shouldn't be closing all modals when a key is pressed, but rather the top most.
Thank you for contribution!
I add a nested modal to the example to test it and ESC key close all modals. Actually, click outside the modal, closes all modals to. Working on both things.
Finally I made a service that is in charge of closing modals on ESC key press and Click outside modal events.