From 1e615d69e1386dcc6db3f578084913676b177dc4 Mon Sep 17 00:00:00 2001 From: Zhaokun Date: Fri, 19 Sep 2025 18:26:13 +0800 Subject: [PATCH] fix: prevent backspace from deleting files when text contains whitespace (#10261) - Change condition from text.trim() === '' to text.length === 0 - Users can now delete whitespace characters (spaces, tabs, newlines) without accidentally deleting attached files - File deletion only occurs when text is completely empty - Maintains existing functionality for file deletion when text is truly empty Fixes: Blank character input causes backspace to incorrectly delete attached images Signed-off-by: zhaokun --- src/renderer/src/pages/home/Inputbar/Inputbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx index 9a130e45ff..5897c4fe45 100644 --- a/src/renderer/src/pages/home/Inputbar/Inputbar.tsx +++ b/src/renderer/src/pages/home/Inputbar/Inputbar.tsx @@ -377,7 +377,7 @@ const Inputbar: FC = ({ assistant: _assistant, setActiveTopic, topic }) = } } - if (event.key === 'Backspace' && text.trim() === '' && files.length > 0) { + if (event.key === 'Backspace' && text.length === 0 && files.length > 0) { setFiles((prev) => prev.slice(0, -1)) return event.preventDefault() }