A platform for community discussion. Free, open, simple.
FIX: Destroy old reply draft when switching to linked topic (#37726)
Régis Hanolfccae023e0b6
diff --git a/frontend/discourse/select-kit/components/composer-actions.js b/frontend/discourse/select-kit/components/composer-actions.jsindex 9915825c582..6b3eb6a81e2 100644--- a/frontend/discourse/select-kit/components/composer-actions.js+++ b/frontend/discourse/select-kit/components/composer-actions.js@@ -287,9 +287,10 @@ export default class ComposerActions extends DropdownSelectBoxComponent {});}- _replyFromExisting(options, post, topic) {- this.composer.closeComposer();- this.composer.open({+ async _replyFromExisting(options, post, topic) {+ await this.composer.destroyDraft();+ this.composer.close();+ await this.composer.open({...options,prependText: this._continuedFromText(post, topic),});diff --git a/spec/system/composer/drafts_spec.rb b/spec/system/composer/drafts_spec.rbindex 55e42bf00ed..fc963150483 100644--- a/spec/system/composer/drafts_spec.rb+++ b/spec/system/composer/drafts_spec.rb@@ -319,4 +319,33 @@ describe "Composer - Drafts", type: :system doendendend++ context "when replying as a linked topic" do+ fab!(:category)++ it "does not leave a stale reply draft after posting a linked topic" do+ topic_page.visit_topic(topic)+ topic_page.click_reply_button++ expect(composer).to be_opened+ composer.fill_content("this is a reply draft")++ try_until_success(reason: "wait for draft to be saved") do+ expect(Draft.where(user: current_user).count).to eq(1)+ end++ composer.open_composer_actions+ composer.select_action(I18n.t("js.composer.composer_actions.reply_as_new_topic.label"))++ expect(composer).to be_opened+ composer.fill_title("This is a linked topic title for testing")+ composer.fill_content("this is a linked topic body content for testing")+ composer.switch_category(category.name)+ composer.create++ expect(composer).to be_closed+ expect(Topic.last.title).to eq("This is a linked topic title for testing")+ expect(Draft.where(user: current_user).count).to eq(0)+ end+ endend