From 60196cc192885346feacd26f59a8b838b88d70cb Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Fri, 12 Jun 2020 14:48:45 +0300 Subject: [PATCH] FIX: Hide bootbox after a negative answer (#10028) Starting to reply and then editing a post was not possible because of a bootbox which kept showing up. --- .../discourse/app/controllers/composer.js | 6 ++++-- test/javascripts/acceptance/composer-test.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js index 3ca2b70f36d..569338907ef 100644 --- a/app/assets/javascripts/discourse/app/controllers/composer.js +++ b/app/assets/javascripts/discourse/app/controllers/composer.js @@ -1040,7 +1040,7 @@ export default Controller.extend({ const keyPrefix = this.model.action === "edit" ? "post.abandon_edit" : "post.abandon"; - let promise = new Promise(resolve => { + let promise = new Promise((resolve, reject) => { if (this.get("model.hasMetaData") || this.get("model.replyDirty")) { bootbox.dialog(I18n.t(keyPrefix + ".confirm"), [ { @@ -1052,8 +1052,10 @@ export default Controller.extend({ if (differentDraft) { this.model.clearState(); this.close(); + resolve(); } - resolve(); + + reject(); } }, { diff --git a/test/javascripts/acceptance/composer-test.js b/test/javascripts/acceptance/composer-test.js index 50b698e3ae0..74f87d5cef5 100644 --- a/test/javascripts/acceptance/composer-test.js +++ b/test/javascripts/acceptance/composer-test.js @@ -271,6 +271,24 @@ QUnit.test("Create a Reply", async assert => { ); }); +QUnit.test("Can edit a post after starting a reply", async 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 click(".topic-post:eq(0) button.show-more-actions"); + await click(".topic-post:eq(0) button.edit"); + + await click("a[data-handler='0']"); + + assert.ok(!visible(".bootbox.modal")); + assert.equal( + find(".d-editor-input").val(), + "this is the content of my reply" + ); +}); + QUnit.test("Posting on a different topic", async assert => { await visit("/t/internationalization-localization/280"); await click("#topic-footer-buttons .btn.create");