auto-focus prompt textarea on every render

This commit is contained in:
Levi Neely 2026-04-26 15:24:53 +02:00
parent 2d378ace4e
commit 1648d99178
1 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import { useState, useRef } from 'preact/hooks'
import { useState, useRef, useEffect } from 'preact/hooks'
interface Props {
running: boolean
@ -10,6 +10,8 @@ export function PromptBar({ running, onSend, onStop }: Props) {
const [value, setValue] = useState('')
const ref = useRef<HTMLTextAreaElement>(null)
useEffect(() => { ref.current?.focus() })
const submit = () => {
const text = value.trim()
if (!text || running) return