Skip to content

Commit 9c8cef4

Browse files
artolshanskyvalorkin
authored andcommitted
fix(modals): fix minimize Safari after press esc (#3605)
fix: after opening any modal and pressing Esc button, browser minimize and only after that modal dissappears close #3313
1 parent 9138363 commit 9c8cef4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/modal/modal-container.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ export class ModalContainerComponent implements OnInit, OnDestroy {
8888
this.hide();
8989
}
9090

91-
@HostListener('window:keydown.esc')
92-
onEsc(): void {
91+
@HostListener('window:keydown.esc', ['$event'])
92+
onEsc(event: any): void {
93+
if (event.keyCode === 27) {
94+
event.preventDefault();
95+
}
96+
9397
if (
9498
this.config.keyboard &&
9599
this.level === this.bsModalService.getModalsCount()

src/modal/modal.directive.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@ export class ModalDirective implements OnDestroy, OnInit {
108108
}
109109

110110
// todo: consider preventing default and stopping propagation
111-
@HostListener('keydown.esc')
112-
onEsc(): void {
111+
@HostListener('window:keydown.esc', ['$event'])
112+
onEsc(event: any): void {
113+
if (event.keyCode === 27) {
114+
event.preventDefault();
115+
}
116+
113117
if (this.config.keyboard) {
114118
this.dismissReason = DISMISS_REASONS.ESC;
115119
this.hide();

0 commit comments

Comments
 (0)