FIX: Bypass draft check when switching to shared draft. (#6782)

FIX: Bypass draft check when switching to shared draft. (#6782)
diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6
index 5e62a28..1897724 100644
--- a/app/assets/javascripts/discourse/controllers/composer.js.es6
+++ b/app/assets/javascripts/discourse/controllers/composer.js.es6
@@ -786,7 +786,14 @@ export default Ember.Controller.extend({
       // or get a draft sequence number
       if (!opts.draft || opts.draftSequence === undefined) {
         return Draft.get(opts.draftKey)
-          .then(data => self.confirmDraftAbandon(data))
+          .then(data => {
+            if (opts.skipDraftCheck) {
+              data.draft = undefined;
+              return data;
+            }
+
+            return self.confirmDraftAbandon(data);
+          })
           .then(data => {
             opts.draft = opts.draft || data.draft;
 
diff --git a/app/assets/javascripts/select-kit/components/composer-actions.js.es6 b/app/assets/javascripts/select-kit/components/composer-actions.js.es6
index 9beff4a..4bafccc 100644
--- a/app/assets/javascripts/select-kit/components/composer-actions.js.es6
+++ b/app/assets/javascripts/select-kit/components/composer-actions.js.es6
@@ -298,6 +298,7 @@ export default DropdownSelectBoxComponent.extend({
     options.action = action;
     options.categoryId = this.get("composerModel.categoryId");
     options.topicTitle = this.get("composerModel.title");
+    options.skipDraftCheck = true;
     this._openComposer(options);
   },
 
diff --git a/test/javascripts/acceptance/composer-actions-test.js.es6 b/test/javascripts/acceptance/composer-actions-test.js.es6
index af74585..da25c05 100644
--- a/test/javascripts/acceptance/composer-actions-test.js.es6
+++ b/test/javascripts/acceptance/composer-actions-test.js.es6
@@ -1,5 +1,6 @@
 import { acceptance, replaceCurrentUser } from "helpers/qunit-helpers";
 import { _clearSnapshots } from "select-kit/components/composer-actions";
+import { toggleCheckDraftPopup } from "discourse/controllers/composer";
 
 acceptance("Composer Actions", {
   loggedIn: true,
@@ -125,11 +126,16 @@ QUnit.test("replying to post - reply_as_new_topic", async assert => {
 });
 
 QUnit.test("shared draft", async assert => {
+  toggleCheckDraftPopup(true);
+
   const composerActions = selectKit(".composer-actions");
 
   await visit("/");
   await click("#create-topic");
 
+  await fillIn("#reply-title", "This is the new text for the title");
+  await fillIn(".d-editor-input", "This is the new text for the post");
+
   await composerActions.expand();
   await composerActions.selectRowByValue("shared_draft");
 
@@ -138,6 +144,8 @@ QUnit.test("shared draft", async assert => {
     I18n.t("composer.create_shared_draft")
   );
   assert.ok(find("#reply-control.composing-shared-draft").length === 1);
+
+  toggleCheckDraftPopup(false);
 });
 
 QUnit.test("hide component if no content", async assert => {

GitHub
sha: 7050ce46