From b468ecfce7dd4f23503786d03688a917f63f4ab5 Mon Sep 17 00:00:00 2001 From: ousugo Date: Fri, 14 Feb 2025 17:06:32 +0800 Subject: [PATCH] feat: Improve textarea cursor positioning on focus --- src/renderer/src/pages/home/Inputbar/Inputbar.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 0ed347b5..2a2424aa 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -511,7 +511,14 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic }) => { ref={textareaRef} style={{ fontSize }} styles={{ textarea: TextareaStyle }} - onFocus={() => setInputFocus(true)} + onFocus={(e: React.FocusEvent) => { + setInputFocus(true) + const textArea = e.target + if (textArea) { + const length = textArea.value.length + textArea.setSelectionRange(length, length) + } + }} onBlur={() => setInputFocus(false)} onInput={onInput} disabled={searching}