FIX: close modals on ESC key and clicking outside

This commit is contained in:
Neil Lalonde 2019-10-28 17:23:21 -04:00
parent 64d51ab45e
commit f686ab988f
2 changed files with 3 additions and 3 deletions

View File

@ -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();
}
},

View File

@ -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");
});