Skip to content

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

FIX: keep composer draft when go back and forth between PM and New Topic. (#16978)

Vinoth Kannan951b3016a472
diff --git a/app/assets/javascripts/discourse/app/models/composer.js b/app/assets/javascripts/discourse/app/models/composer.js
index d5bed57f0f5..396de7cefbc 100644
--- a/app/assets/javascripts/discourse/app/models/composer.js
+++ b/app/assets/javascripts/discourse/app/models/composer.js
@@ -871,7 +871,8 @@ const Composer = RestModel.extend({
this.set("title", opts.title);
}
- this.set("originalText", opts.draft ? "" : this.reply);
+ const isDraft = opts.draft || opts.skipDraftCheck;
+ this.set("originalText", isDraft ? "" : this.reply);
if (this.canEditTitle) {
if (isEmpty(this.title) && this.title !== "") {
diff --git a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
index d0bb7d62ab4..06796dd2306 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/composer-actions-test.js
@@ -38,6 +38,12 @@ acceptance("Composer Actions", function (needs) {
assert.ok(queryAll("#reply-title").val(), "this is the title");
assert.ok(queryAll(".d-editor-input").val(), "this is the reply");
+
+ await click("#reply-control a.cancel");
+ assert.ok(
+ exists(".discard-draft-modal.modal"),
+ "it pops up the discard drafts modal"
+ );
});
test("replying to post", async function (assert) {