auto-focus prompt textarea on every render
This commit is contained in:
parent
2d378ace4e
commit
1648d99178
|
|
@ -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
|
||||
|
|
|
|||
Reference in New Issue