From 2705d83d6cffdd8cde6679e5e6e4610e6eb71545 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 14 Oct 2024 23:01:46 +0530 Subject: [PATCH] Focus input on submission and fix scroll (#441) --- components/custom/chat.tsx | 5 +-- components/custom/multimodal-input.tsx | 13 ++++++-- components/custom/use-scroll-to-bottom.ts | 2 ++ components/custom/use-window-size.tsx | 39 +++++++++++++++++++++++ components/custom/weather.tsx | 10 ++++-- 5 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 components/custom/use-window-size.tsx diff --git a/components/custom/chat.tsx b/components/custom/chat.tsx index bdd8424..382a89c 100644 --- a/components/custom/chat.tsx +++ b/components/custom/chat.tsx @@ -40,15 +40,16 @@ export function Chat({ > {messages.length === 0 && } - {messages.map((message, index) => ( + {messages.map((message) => ( ))} +
void; }) { const textareaRef = useRef(null); + const { width } = useWindowSize(); useEffect(() => { if (textareaRef.current) { @@ -89,7 +91,11 @@ export function MultimodalInput({ }); setAttachments([]); - }, [attachments, handleSubmit, setAttachments]); + + if (width && width > 768) { + textareaRef.current?.focus(); + } + }, [attachments, handleSubmit, setAttachments, width]); const uploadFile = async (file: File) => { const formData = new FormData(); @@ -242,7 +248,8 @@ export function MultimodalInput({
-
{`H:${currentHigh}° L:${currentLow}°`}
+
{`H:${n(currentHigh)}° L:${n(currentLow)}°`}
@@ -296,7 +300,7 @@ export function Weather({ )} />
- {displayTemperatures[index]} + {n(displayTemperatures[index])} {weatherAtLocation.hourly_units.temperature_2m}