Skip to content

Commit 509cdc5

Browse files
snoopy83Jikai XujosStorer
authored
feat: auto focus to inputbox (issue: #243) (pr: #249)
* Put the cursor back to input area after the answer generated * move inputbox focus to lonely useEffect --------- Co-authored-by: Jikai Xu <“[email protected]”> Co-authored-by: josc146 <[email protected]>
1 parent 381a2b3 commit 509cdc5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/components/InputBox/index.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export function InputBox({ onSubmit, enabled }) {
1212
updateRefHeight(inputRef)
1313
})
1414

15+
useEffect(() => {
16+
if (enabled) inputRef.current.focus()
17+
}, [enabled])
18+
1519
const onKeyDown = (e) => {
1620
e.stopPropagation()
1721
if (e.keyCode === 13 && e.shiftKey === false) {

0 commit comments

Comments
 (0)