From 75bc6b6c0845836299b6be122118bf89fd8f59db Mon Sep 17 00:00:00 2001 From: Hsuan Lee Date: Thu, 16 Nov 2017 16:27:43 +0800 Subject: [PATCH] feat(module:modal): support disable the esc key to close (#567) --- src/components/modal/nz-confirm.component.ts | 4 +++- src/components/modal/nz-modal.component.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/modal/nz-confirm.component.ts b/src/components/modal/nz-confirm.component.ts index 79cbf9ee8e..21863e8646 100644 --- a/src/components/modal/nz-confirm.component.ts +++ b/src/components/modal/nz-confirm.component.ts @@ -192,7 +192,9 @@ export class NzConfirmComponent implements OnInit, OnDestroy { @HostListener('keydown.esc', [ '$event' ]) onEsc(e): void { - this.subject.next('onCancel'); + if (this._maskClosable) { + this.subject.next('onCancel'); + } } @HostListener('keydown.enter', [ '$event' ]) diff --git a/src/components/modal/nz-modal.component.ts b/src/components/modal/nz-modal.component.ts index 9cc011627f..bbbd39a62e 100644 --- a/src/components/modal/nz-modal.component.ts +++ b/src/components/modal/nz-modal.component.ts @@ -241,7 +241,9 @@ export class NzModalComponent implements OnInit, OnDestroy, AfterViewInit { @HostListener('keydown.esc', [ '$event' ]) onEsc(e): void { - this.clickCancel(e); + if (this._maskClosable) { + this.clickCancel(e); + } } setStyles(origin?): void {