Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

compose: Add parameter `replace_all` to `insert_and_scroll_into_view`.

N-Shar-maef0be2289937
diff --git a/web/src/compose_ui.ts b/web/src/compose_ui.ts
index 17487bb557d..f9e0d53b7d6 100644
--- a/web/src/compose_ui.ts
+++ b/web/src/compose_ui.ts
@@ -68,9 +68,15 @@ export function autosize_textarea($textarea: JQuery<HTMLTextAreaElement>): void
export function insert_and_scroll_into_view(
content: string,
$textarea: JQuery<HTMLTextAreaElement>,
+ replace_all = false,
): void {
- insertTextIntoField($textarea[0], content);
- // Blurring and refocusing ensures the cursor / selection is in view.
+ if (replace_all) {
+ setFieldText($textarea[0], content);
+ } else {
+ insertTextIntoField($textarea[0], content);
+ }
+ // Blurring and refocusing ensures the cursor / selection is in view
+ // in chromium browsers.
$textarea.trigger("blur");
$textarea.trigger("focus");
autosize_textarea($textarea);