auto focus
This commit is contained in:
parent
5ce7f7b312
commit
8466355f59
1 changed files with 7 additions and 0 deletions
|
|
@ -44,6 +44,7 @@ export default function ChatPage() {
|
||||||
const [isDragOver, setIsDragOver] = useState(false)
|
const [isDragOver, setIsDragOver] = useState(false)
|
||||||
const dragCounterRef = useRef(0)
|
const dragCounterRef = useRef(0)
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null)
|
const messagesEndRef = useRef<HTMLDivElement>(null)
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" })
|
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" })
|
||||||
|
|
@ -152,6 +153,11 @@ export default function ChatPage() {
|
||||||
scrollToBottom()
|
scrollToBottom()
|
||||||
}, [messages, streamingMessage])
|
}, [messages, streamingMessage])
|
||||||
|
|
||||||
|
// Auto-focus the input on component mount
|
||||||
|
useEffect(() => {
|
||||||
|
inputRef.current?.focus()
|
||||||
|
}, [])
|
||||||
|
|
||||||
const handleSSEStream = async (userMessage: Message) => {
|
const handleSSEStream = async (userMessage: Message) => {
|
||||||
const apiEndpoint = endpoint === "chat" ? "/api/chat" : "/api/langflow"
|
const apiEndpoint = endpoint === "chat" ? "/api/chat" : "/api/langflow"
|
||||||
|
|
||||||
|
|
@ -843,6 +849,7 @@ export default function ChatPage() {
|
||||||
{/* Input Area */}
|
{/* Input Area */}
|
||||||
<form onSubmit={handleSubmit} className="flex gap-2 flex-shrink-0 w-full">
|
<form onSubmit={handleSubmit} className="flex gap-2 flex-shrink-0 w-full">
|
||||||
<Input
|
<Input
|
||||||
|
ref={inputRef}
|
||||||
value={input}
|
value={input}
|
||||||
onChange={(e) => setInput(e.target.value)}
|
onChange={(e) => setInput(e.target.value)}
|
||||||
placeholder="Ask a question about your documents..."
|
placeholder="Ask a question about your documents..."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue