From 25c9b05bd0eccf4c56690b6617ee1b57c45571ef Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 27 Nov 2021 20:25:01 -0800 Subject: [PATCH] compose: Fix cursor position loss in quote-and-reply. If you used "Quote and reply" to start composing a message, and started typing before receiving the original message body from the server, we ended up resetting your cursor to the start of the line after the quote for two reasons: * We were incorrectly fetching the pre_cursor for our replacement operation before doing the server fetch, which meant we ignored any editing done while waiting for the server to respond. * Worse, we actually fetched the original cursor position before inserting the "[Quoting...]" placeholder text. So we were guaranteed to have at least some amount of error in the cursor position. Fixes #20379. --- static/js/compose_actions.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js index 7bbea45264..e44c35fa69 100644 --- a/static/js/compose_actions.js +++ b/static/js/compose_actions.js @@ -482,8 +482,6 @@ export function quote_and_reply(opts) { respond_to_message(opts); } - const prev_caret = textarea.caret(); - compose_ui.insert_syntax_and_focus("[Quoting…]\n", textarea); function replace_content(message) { @@ -492,6 +490,7 @@ export function quote_and_reply(opts) { // ```quote // message content // ``` + const prev_caret = textarea.caret(); let content = $t( {defaultMessage: "{username} [said]({link_to_message}):"}, {