Home > database >  How can I stop a modal from closing when I press the ESC key so that a function is called instead th
How can I stop a modal from closing when I press the ESC key so that a function is called instead th

Time:10-23

For the moment I have managed with HostListener to call that method but this should happen without closing the modal.

@HostListener('document:keydown.escape', ['$event']) onKeydownHandler(event: KeyboardEvent) {
    console.log(event);
if(this.deleteIsAllowed()){
 this.showDialogForClosing();
 }
}

CodePudding user response:

maybe you can try to use event.preventDefault() or event.stopPropagation().

Can you please give us the library name you are using? Sometimes you can configure the closing behaviour of the modal.

  • Related