Skip to content

A platform for community discussion. Free, open, simple.

FIX: close modals on ESC key and clicking outside

Neil Lalondef686ab988fd4
diff --git a/app/assets/javascripts/discourse/components/d-modal.js.es6 b/app/assets/javascripts/discourse/components/d-modal.js.es6
index b8dbcc49670..0c83f529ad9 100644
--- a/app/assets/javascripts/discourse/components/d-modal.js.es6
+++ b/app/assets/javascripts/discourse/components/d-modal.js.es6
@@ -32,7 +32,7 @@ export default Component.extend({
setUp() {
$("html").on("keydown.discourse-modal", e => {
if (e.which === 27 && this.dismissable) {
- Ember.run.next(() => $(".modal-header a.close").click());
+ Ember.run.next(() => $(".modal-header button.modal-close").click());
}
if (e.which === 13 && this.triggerClickOnEnter(e)) {
@@ -73,7 +73,7 @@ export default Component.extend({
// Delegate click to modal close if clicked outside.
// We do this because some CSS of ours seems to cover
// the backdrop and makes it unclickable.
- $(".modal-header a.close").click();
+ $(".modal-header button.modal-close").click();
}
},
diff --git a/test/javascripts/acceptance/category-edit-test.js.es6 b/test/javascripts/acceptance/category-edit-test.js.es6
index 690e028ead7..fed9c845312 100644
--- a/test/javascripts/acceptance/category-edit-test.js.es6
+++ b/test/javascripts/acceptance/category-edit-test.js.es6
@@ -13,7 +13,7 @@ QUnit.test("Can open the category modal", async assert => {
await click(".edit-category");
assert.ok(visible(".d-modal"), "it pops up a modal");
- await click("a.close");
+ await click("button.modal-close");
assert.ok(!visible(".d-modal"), "it closes the modal");
});