From 4b2300eb8fc37f827936a312bea488722b0a67fa Mon Sep 17 00:00:00 2001 From: Athos Georgiou Date: Thu, 19 Dec 2024 15:21:42 +0200 Subject: [PATCH] fix: clean up code formatting and improve readability in PureMultimodalInput component --- components/multimodal-input.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/components/multimodal-input.tsx b/components/multimodal-input.tsx index 8b9faf6a6..2ebeea9ea 100644 --- a/components/multimodal-input.tsx +++ b/components/multimodal-input.tsx @@ -55,13 +55,13 @@ function PureMultimodalInput({ setMessages: Dispatch>>; append: ( message: Message | CreateMessage, - chatRequestOptions?: ChatRequestOptions, + chatRequestOptions?: ChatRequestOptions ) => Promise; handleSubmit: ( event?: { preventDefault?: () => void; }, - chatRequestOptions?: ChatRequestOptions, + chatRequestOptions?: ChatRequestOptions ) => void; className?: string; }) { @@ -77,13 +77,15 @@ function PureMultimodalInput({ const adjustHeight = () => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; - textareaRef.current.style.height = `${textareaRef.current.scrollHeight + 2}px`; + textareaRef.current.style.height = `${ + textareaRef.current.scrollHeight + 2 + }px`; } }; const [localStorageInput, setLocalStorageInput] = useLocalStorage( 'input', - '', + '' ); useEffect(() => { @@ -169,7 +171,7 @@ function PureMultimodalInput({ const uploadPromises = files.map((file) => uploadFile(file)); const uploadedAttachments = await Promise.all(uploadPromises); const successfullyUploadedAttachments = uploadedAttachments.filter( - (attachment) => attachment !== undefined, + (attachment) => attachment !== undefined ); setAttachments((currentAttachments) => [ @@ -182,7 +184,7 @@ function PureMultimodalInput({ setUploadQueue([]); } }, - [setAttachments], + [setAttachments] ); return ( @@ -229,12 +231,13 @@ function PureMultimodalInput({ onChange={handleInput} className={cx( 'min-h-[24px] max-h-[calc(75dvh)] overflow-hidden resize-none rounded-2xl !text-base bg-muted pb-10 dark:border-zinc-700', - className, + className )} rows={2} autoFocus onKeyDown={(event) => { - if (event.key === 'Enter' && !event.shiftKey) { + // Only handle Enter submission on desktop + if (event.key === 'Enter' && !event.shiftKey && width > 768) { event.preventDefault(); if (isLoading) { @@ -273,7 +276,7 @@ export const MultimodalInput = memo( if (!equal(prevProps.attachments, nextProps.attachments)) return false; return true; - }, + } ); function PureAttachmentsButton({