From 4e57cd3718d47696a74174357932ab376a708fd3 Mon Sep 17 00:00:00 2001 From: Akira Sudoh Date: Wed, 17 Apr 2019 05:52:12 +0900 Subject: [PATCH] fix(modal): prevent bubbling on ESC on inactive Fixes #2312. --- src/components/modal/modal.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/modal/modal.js b/src/components/modal/modal.js index 820ca908cd9b..c1036c62acb2 100644 --- a/src/components/modal/modal.js +++ b/src/components/modal/modal.js @@ -137,7 +137,8 @@ class Modal extends mixin(createComponent, initComponentByLauncher, eventedShowH this._handleKeydownListener = this.manage( on(this.element.ownerDocument.body, 'keydown', evt => { - if (evt.which === 27) { + // Avoid running `evt.stopPropagation()` only when modal is shown + if (evt.which === 27 && this.shouldStateBeChanged('hidden')) { evt.stopPropagation(); this.hide(evt); }