Skip to content

Commit

Permalink
fix(modals): fix minimize Safari after press esc (#3605)
Browse files Browse the repository at this point in the history
fix: after opening any modal and pressing Esc button, browser minimize and only after that modal dissappears

close #3313
  • Loading branch information
artolshansky authored and valorkin committed Mar 13, 2018
1 parent 9138363 commit 9c8cef4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/modal/modal-container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ export class ModalContainerComponent implements OnInit, OnDestroy {
this.hide();
}

@HostListener('window:keydown.esc')
onEsc(): void {
@HostListener('window:keydown.esc', ['$event'])
onEsc(event: any): void {
if (event.keyCode === 27) {
event.preventDefault();
}

if (
this.config.keyboard &&
this.level === this.bsModalService.getModalsCount()
Expand Down
8 changes: 6 additions & 2 deletions src/modal/modal.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ export class ModalDirective implements OnDestroy, OnInit {
}

// todo: consider preventing default and stopping propagation
@HostListener('keydown.esc')
onEsc(): void {
@HostListener('window:keydown.esc', ['$event'])
onEsc(event: any): void {
if (event.keyCode === 27) {
event.preventDefault();
}

if (this.config.keyboard) {
this.dismissReason = DISMISS_REASONS.ESC;
this.hide();
Expand Down

0 comments on commit 9c8cef4

Please sign in to comment.