FIX: Dismiss modal when "Keep Editing" is used (#21117)

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
Penar Musaraj 2023-04-17 17:44:21 -04:00 committed by GitHub
parent d3f3914ade
commit b869d35f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 4 deletions

View File

@ -1468,8 +1468,6 @@ export default class ComposerController extends Controller {
this.appEvents.trigger("composer:cancelled"); this.appEvents.trigger("composer:cancelled");
return resolve(); return resolve();
}, },
// needed to resume saving drafts if composer stays open
onDismissModal: () => resolve(),
}); });
} else { } else {
// it is possible there is some sort of crazy draft with no body ... just give up on it // it is possible there is some sort of crazy draft with no body ... just give up on it

View File

@ -13,8 +13,7 @@ export default Controller.extend(ModalFunctionality, {
this.send("closeModal"); this.send("closeModal");
}, },
async dismissModal() { dismissModal() {
await this.onDismissModal();
this.send("closeModal"); this.send("closeModal");
}, },
}, },

View File

@ -370,6 +370,26 @@ acceptance("Composer", function (needs) {
); );
}); });
test("Can Keep Editing when replying on a different topic", async function (assert) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .create");
await fillIn(".d-editor-input", "this is the content of my reply");
await visit("/t/this-is-a-test-topic/9");
await click("#topic-footer-buttons .create");
assert.ok(visible(".discard-draft-modal.modal"));
await click(".modal-footer button.keep-editing");
assert.ok(invisible(".discard-draft-modal.modal"));
assert.strictEqual(
query(".d-editor-input").value,
"this is the content of my reply",
"composer does not switch when using Keep Editing button"
);
});
test("Posting on a different topic", async function (assert) { test("Posting on a different topic", async function (assert) {
await visit("/t/internationalization-localization/280"); await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create"); await click("#topic-footer-buttons .btn.create");