Skip to content

Commit

Permalink
feat(modals): dont call hide() func on esc if modal is not shown (#4221)
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin authored Apr 13, 2018
1 parent 605efd1 commit 9254837
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/modal/modal-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export class ModalContainerComponent implements OnInit, OnDestroy {

@HostListener('window:keydown.esc', ['$event'])
onEsc(event: any): void {
if (!this.isShown) {
return;
}

if (event.keyCode === 27) {
event.preventDefault();
}
Expand Down
4 changes: 4 additions & 0 deletions src/modal/modal.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ export class ModalDirective implements OnDestroy, OnInit {
// todo: consider preventing default and stopping propagation
@HostListener('window:keydown.esc', ['$event'])
onEsc(event: any): void {
if (!this._isShown) {
return;
}

if (event.keyCode === 27) {
event.preventDefault();
}
Expand Down

0 comments on commit 9254837

Please sign in to comment.