From cb28bd4e7e713682361bf90caad6f0139afb0d8d Mon Sep 17 00:00:00 2001 From: balibabu Date: Mon, 3 Aug 2026 13:09:13 +0800 Subject: [PATCH] Fix: Upload an image without filling in any text and press Enter; the image should not disappear. (#17632) --- web/src/components/message-input/next.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/src/components/message-input/next.tsx b/web/src/components/message-input/next.tsx index e3a0888c2a..f4dc9364a4 100644 --- a/web/src/components/message-input/next.tsx +++ b/web/src/components/message-input/next.tsx @@ -152,10 +152,13 @@ export function NextMessageInput({ }, []); const submit = React.useCallback(() => { - if (isUploading || sendLoading) return; + // Mirror the send button's disabled condition so pressing Enter with an + // empty message does nothing — previously it cleared the uploaded file + // list without sending anything. + if (sendDisabled || isUploading || sendLoading || !value.trim()) return; pressEnter(); setFiles([]); - }, [isUploading, sendLoading, pressEnter]); + }, [sendDisabled, isUploading, sendLoading, value, pressEnter]); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) {