From b01aca906697122492d7670dfac5b30f3639e90b Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Mon, 20 Jan 2025 09:52:48 +0800 Subject: [PATCH] fix: prevent unnecessary route changes and trim input field on change --- src/renderer/src/windows/mini/home/HomeWindow.tsx | 2 +- src/renderer/src/windows/mini/home/components/InputBar.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/windows/mini/home/HomeWindow.tsx b/src/renderer/src/windows/mini/home/HomeWindow.tsx index 870c75a7..fec0c6e4 100644 --- a/src/renderer/src/windows/mini/home/HomeWindow.tsx +++ b/src/renderer/src/windows/mini/home/HomeWindow.tsx @@ -59,7 +59,7 @@ const HomeWindow: FC = () => { if (e.key === 'Enter') { e.preventDefault() - if (text.trim() === '') { + if (textRef.current.trim() === '') { return } setRoute('chat') diff --git a/src/renderer/src/windows/mini/home/components/InputBar.tsx b/src/renderer/src/windows/mini/home/components/InputBar.tsx index 689ce560..012aeebc 100644 --- a/src/renderer/src/windows/mini/home/components/InputBar.tsx +++ b/src/renderer/src/windows/mini/home/components/InputBar.tsx @@ -24,7 +24,7 @@ const InputBar: FC = ({ text, model, placeholder, handleKeyDown, bordered={false} autoFocus onKeyDown={handleKeyDown} - onChange={(e) => setText(e.target.value.trim())} + onChange={(e) => setText(e.target.value)} disabled={generating} />