diff --git a/app/assets/javascripts/discourse/app/components/d-modal.js b/app/assets/javascripts/discourse/app/components/d-modal.js index e338cc6a619..7a5b3cab8bc 100644 --- a/app/assets/javascripts/discourse/app/components/d-modal.js +++ b/app/assets/javascripts/discourse/app/components/d-modal.js @@ -36,7 +36,7 @@ export default Component.extend({ setUp() { $("html").on("keyup.discourse-modal", e => { //only respond to events when the modal is visible - if ($("#discourse-modal:visible").length > 0) { + if (!this.element.classList.contains("hidden")) { if (e.which === 27 && this.dismissable) { next(() => $(".modal-header button.modal-close").click()); }