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

Previously, draft get destroyed accidentally when we switch to PM with the below steps
1. Click “New Topic”
2. Type in the body
3. Switch to “New Message”
4. Click “cancel”
This commit is contained in:
Vinoth Kannan 2022-06-02 23:36:34 +05:30 committed by GitHub
parent 8e75f8c371
commit 951b3016a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -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 !== "") {

View File

@ -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) {