mirror of
https://github.com/zulip/zulip.git
synced 2025-10-30 11:33:51 +00:00
drafts: Append a space to draft when restoring it.
If a user starts typing before they see that a draft was restored, this makes that experience a little smoother by adding some separation between the old draft and the new text.
This commit is contained in:
@@ -54,7 +54,7 @@ async function test_restore_stream_message_draft_by_opening_compose_box(page: Pa
|
||||
await 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: Pa
|
||||
await 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});
|
||||
|
||||
@@ -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 + " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user