From c8680a4bf19056f3056c99a82d033ce6509854da Mon Sep 17 00:00:00 2001 From: snoopy83 Date: Thu, 20 Apr 2023 23:20:51 +1000 Subject: [PATCH] feat: auto focus to inputbox (issue: #243) (pr: #249) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Put the cursor back to input area after the answer generated * move inputbox focus to lonely useEffect --------- Co-authored-by: Jikai Xu <“jikai.xu@insigniafinancial.com.au”> Co-authored-by: josc146 --- src/components/InputBox/index.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/InputBox/index.jsx b/src/components/InputBox/index.jsx index b49c791..89e8e5c 100644 --- a/src/components/InputBox/index.jsx +++ b/src/components/InputBox/index.jsx @@ -12,6 +12,10 @@ export function InputBox({ onSubmit, enabled }) { updateRefHeight(inputRef) }) + useEffect(() => { + if (enabled) inputRef.current.focus() + }, [enabled]) + const onKeyDown = (e) => { e.stopPropagation() if (e.keyCode === 13 && e.shiftKey === false) {