Skip to content

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

FIX: Always save post drafts no matter content length (#35540)

Martin Brennanb95239c8a9a1
diff --git a/frontend/discourse/app/models/composer.js b/frontend/discourse/app/models/composer.js
index cdad1de9d86..cc3759ab5fa 100644
--- a/frontend/discourse/app/models/composer.js
+++ b/frontend/discourse/app/models/composer.js
@@ -1336,23 +1336,16 @@ export default class Composer extends RestModel {
return false;
}
- // Do not save when drafts are disabled
if (this.disableDrafts) {
return false;
}
+ // Title is only edited when editing topic OP or making a new topic.
if (this.canEditTitle) {
- // Save title and/or post body
if (isEmpty(this.title) && isEmpty(this.reply)) {
return false;
}
-
- // Do not save when both title and reply's length are too small
- if (!this.titleLengthValid && this.replyLength < this.minimumPostLength) {
- return false;
- }
} else {
- // Do not save when there is no reply
if (isEmpty(this.reply)) {
return false;
}
diff --git a/spec/system/composer/drafts_spec.rb b/spec/system/composer/drafts_spec.rb
index fce9bea895b..55e42bf00ed 100644
--- a/spec/system/composer/drafts_spec.rb
+++ b/spec/system/composer/drafts_spec.rb
@@ -41,17 +41,31 @@ describe "Composer - Drafts", type: :system do
end
end
- context "when only title is specified and it is too short" do
- it "does not save the draft or show a toast" do
+ context "when only title is specified and it is less than min_topic_title_length" do
+ it "does saves the draft and shows a toast" do
visit "/new-topic"
expect(composer).to be_opened
- composer.fill_title("test")
+ composer.fill_title("x")
composer.close
expect(composer).to be_closed
- expect(toasts).to have_no_message
- expect(Draft.where(user: current_user).count).to eq(0)
+ expect(toasts).to have_success(I18n.t("js.composer.draft_saved"))
+ expect(Draft.where(user: current_user).count).to eq(1)
+ end
+ end
+
+ context "when only body is specified and it is less than min_post_length" do
+ it "does saves the draft and shows a toast" do
+ visit "/new-topic"
+
+ expect(composer).to be_opened
+ composer.fill_content("x")
+ composer.close
+ expect(composer).to be_closed
+
+ expect(toasts).to have_success(I18n.t("js.composer.draft_saved"))
+ expect(Draft.where(user: current_user).count).to eq(1)
end
end
end