From fb54ebf116c2d72104c5bfaadd1804d758212c5c Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 22 Aug 2025 17:29:49 +0000 Subject: [PATCH] Add autofocus on chat --- frontend/src/ChatInput.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/ChatInput.jsx b/frontend/src/ChatInput.jsx index 060fcf4..8f2cf44 100644 --- a/frontend/src/ChatInput.jsx +++ b/frontend/src/ChatInput.jsx @@ -1,7 +1,16 @@ -import React, { useState } from "react"; +// src/ChatInput.jsx +import React, { useState, useRef, useEffect } from "react"; export default function ChatInput({ onSend, loading }) { const [value, setValue] = useState(""); + const textareaRef = useRef(null); + + // Autofocus on mount and after each retrieval + useEffect(() => { + if (!loading && textareaRef.current) { + textareaRef.current.focus(); + } + }, [loading]); const handleKeyDown = (e) => { if (e.key === "Enter" && !e.shiftKey) { @@ -16,6 +25,7 @@ export default function ChatInput({ onSend, loading }) { return (