Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose: When editing message/s, quote into the last focused edit box.
N-Shar-ma2c318b680bdb
diff --git a/web/src/compose_reply.js b/web/src/compose_reply.jsindex 79777eac006..3cba3848ae1 100644--- a/web/src/compose_reply.js+++ b/web/src/compose_reply.js@@ -125,13 +125,19 @@ export function reply_with_mention(opts) {}export function quote_and_reply(opts) {- const $textarea = $("textarea#compose-textarea");const message_id = opts.message_id || message_lists.current.selected_id();const message = message_lists.current.get(message_id);const quoting_placeholder = $t({defaultMessage: "[Quoting…]"});- if (!compose_state.has_message_content()) {+ // If the last compose type textarea focused on is still in the DOM, we add+ // the quote in that textarea, else we default to the compose box.+ const $textarea = compose_state.get_last_focused_compose_type_input()?.isConnected+ ? $(compose_state.get_last_focused_compose_type_input())+ : $("textarea#compose-textarea");++ if ($textarea.attr("id") === "compose-textarea" && !compose_state.has_message_content()) {// The user has not started typing a message,+ // but is quoting into the compose box,// so we will re-open the compose box.// (If you did re-open the compose box, you// are prone to glitches where you select the@@ -160,7 +166,7 @@ export function quote_and_reply(opts) {content += `${fence}quote\n${message.raw_content}\n${fence}`;compose_ui.replace_syntax(quoting_placeholder, content, $textarea);- compose_ui.autosize_textarea($("textarea#compose-textarea"));+ compose_ui.autosize_textarea($textarea);}if (message && message.raw_content) {diff --git a/web/tests/compose_actions.test.js b/web/tests/compose_actions.test.jsindex a75c9547865..1aa9dca72ac 100644--- a/web/tests/compose_actions.test.js+++ b/web/tests/compose_actions.test.js@@ -414,6 +414,7 @@ test("quote_and_reply", ({disallow, override, override_rewire}) => {};$("textarea#compose-textarea").caret = noop;+ $("textarea#compose-textarea").attr("id", "compose-textarea");replaced = false;expected_replacement =diff --git a/web/tests/compose_ui.test.js b/web/tests/compose_ui.test.jsindex 0f4585e13de..ee73db9fbea 100644--- a/web/tests/compose_ui.test.js+++ b/web/tests/compose_ui.test.js@@ -328,6 +328,7 @@ run_test("quote_and_reply", ({override, override_rewire}) => {}};$("textarea#compose-textarea")[0] = "compose-textarea";+ $("textarea#compose-textarea").attr("id", "compose-textarea");override(text_field_edit, "insert", (elt, syntax) => {assert.equal(elt, "compose-textarea");assert.equal(syntax, "\n\ntranslated: [Quoting…]\n\n");