Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
drafts: Append a space to draft when restoring it.
evykassirerfd4246def52f
diff --git a/web/e2e-tests/drafts.test.ts b/web/e2e-tests/drafts.test.tsindex 308e36c6b2f..a1cd12f6355 100644--- a/web/e2e-tests/drafts.test.ts+++ b/web/e2e-tests/drafts.test.ts@@ -54,7 +54,7 @@ async function test_restore_stream_message_draft_by_opening_compose_box(page: Paawait common.check_compose_state(page, {stream: "Denmark",topic: "tests",- content: "Test stream message.",+ content: "Test stream message. ",});await page.click("#compose_close");await page.waitForSelector("#send_message_form", {visible: false});@@ -74,7 +74,7 @@ async function test_restore_private_message_draft_by_opening_composebox(page: Paawait page.waitForSelector("#private_message_recipient", {visible: true});await common.check_form_contents(page, "form#send_message_form", {- content: "Test direct message.",+ content: "Test direct message. ",});await page.click("#compose_close");await page.waitForSelector("#private_message_recipient", {visible: false});diff --git a/web/src/compose_actions.ts b/web/src/compose_actions.tsindex 3df09dd60a7..3b4dae39b69 100644--- a/web/src/compose_actions.ts+++ b/web/src/compose_actions.ts@@ -312,7 +312,12 @@ export function start(raw_opts: ComposeActionsStartOpts): void {const possible_last_draft = drafts.get_last_draft_based_on_compose_state();if (possible_last_draft !== undefined) {opts.draft_id = possible_last_draft.id;- opts.content = possible_last_draft.content;+ // Add a space at the end so that if the user starts typing+ // as soon as the composebox opens, they have a bit of separation+ // from the restored draft. This won't result in a long trail of+ // spaces if a draft is restored several times, because we trim+ // whitespace whenever we save drafts.+ opts.content = possible_last_draft.content + " ";}}