Skip to content

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

FIX: ensures event builder correctly sets the description (#33700)

Joffrey JAFFEUX1f97cf4229ff
diff --git a/plugins/discourse-calendar/assets/javascripts/discourse/components/modal/post-event-builder.gjs b/plugins/discourse-calendar/assets/javascripts/discourse/components/modal/post-event-builder.gjs
index f2438c59ea5..c5d90bae553 100644
--- a/plugins/discourse-calendar/assets/javascripts/discourse/components/modal/post-event-builder.gjs
+++ b/plugins/discourse-calendar/assets/javascripts/discourse/components/modal/post-event-builder.gjs
@@ -274,6 +274,12 @@ export default class PostEventBuilder extends Component {
this.event,
this.siteSettings
);
+
+ const description = eventParams.description
+ ? `${eventParams.description}\n`
+ : "";
+ delete eventParams.description;
+
const markdownParams = [];
Object.keys(eventParams).forEach((key) => {
let value = eventParams[key];
@@ -281,7 +287,7 @@ export default class PostEventBuilder extends Component {
});
this.args.model.toolbarEvent.addText(
- `[event ${markdownParams.join(" ")}]\n[/event]`
+ `[event ${markdownParams.join(" ")}]\n${description}[/event]`
);
this.args.closeModal();
}
diff --git a/plugins/discourse-calendar/spec/system/post_event_spec.rb b/plugins/discourse-calendar/spec/system/post_event_spec.rb
index e25009f81c6..0c0b6112b83 100644
--- a/plugins/discourse-calendar/spec/system/post_event_spec.rb
+++ b/plugins/discourse-calendar/spec/system/post_event_spec.rb
@@ -59,6 +59,26 @@ describe "Post event", type: :system do
)
expect(page).to have_css(".event-description a[href='http://example.com']")
end
+
+ it "correctly builds a multiline description", timezone: "Europe/Paris" do
+ visit("/new-topic")
+
+ time = Time.now.in_time_zone("Europe/Paris").strftime("%Y-%m-%d %H:%M")
+
+ EXPECTED_BBCODE = <<~EVENT
+ [event start="#{time}" status="public" timezone="Europe/Paris" allowedGroups="trust_level_0"]
+ foo
+ bar
+ [/event]
+ EVENT
+
+ find(".toolbar-menu__options-trigger").click
+ click_button(I18n.t("js.discourse_post_event.builder_modal.attach"))
+
+ post_event_form_page.fill_description("foo\nbar").submit
+
+ expect(composer).to have_value(EXPECTED_BBCODE.strip)
+ end
end
context "when showing local time", timezone: "Australia/Brisbane" do