Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ui_util: Update `place_caret_at_end` to also work for input fields.
Hardik Dharmani17ae99f43631
diff --git a/web/src/ui_util.ts b/web/src/ui_util.tsindex 43f1bbbd734..a04aa362295 100644--- a/web/src/ui_util.ts+++ b/web/src/ui_util.ts@@ -9,13 +9,16 @@ import * as keydown_util from "./keydown_util";// https://stackoverflow.com/questions/4233265/contenteditable-set-caret-at-the-end-of-the-text-cross-browserexport function place_caret_at_end(el: HTMLElement): void {el.focus();-- const range = document.createRange();- range.selectNodeContents(el);- range.collapse(false);- const sel = window.getSelection();- sel?.removeAllRanges();- sel?.addRange(range);+ if (el instanceof HTMLInputElement) {+ el.setSelectionRange(el.value.length, el.value.length);+ } else {+ const range = document.createRange();+ range.selectNodeContents(el);+ range.collapse(false);+ const sel = window.getSelection();+ sel?.removeAllRanges();+ sel?.addRange(range);+ }}export function blur_active_element(): void {