Pārlūkot izejas kodu

enh:setfocus after voice input (#7317)

呆萌闷油瓶 8 mēneši atpakaļ
vecāks
revīzija
fcb6921b57
1 mainītis faili ar 6 papildinājumiem un 1 dzēšanām
  1. 6 1
      web/app/components/base/chat/chat/chat-input.tsx

+ 6 - 1
web/app/components/base/chat/chat/chat-input.tsx

@@ -49,6 +49,7 @@ const ChatInput: FC<ChatInputProps> = ({
   const { t } = useTranslation()
   const { notify } = useContext(ToastContext)
   const [voiceInputShow, setVoiceInputShow] = useState(false)
+  const textAreaRef = useRef<HTMLTextAreaElement>(null)
   const {
     files,
     onUpload,
@@ -176,6 +177,7 @@ const ChatInput: FC<ChatInputProps> = ({
             )
           }
           <Textarea
+            ref={textAreaRef}
             className={`
               block w-full px-2 pr-[118px] py-[7px] leading-5 max-h-none text-sm text-gray-700 outline-none appearance-none resize-none
               ${visionConfig?.enabled && 'pl-12'}
@@ -234,7 +236,10 @@ const ChatInput: FC<ChatInputProps> = ({
             voiceInputShow && (
               <VoiceInput
                 onCancel={() => setVoiceInputShow(false)}
-                onConverted={text => setQuery(text)}
+                onConverted={(text) => {
+                  setQuery(text)
+                  textAreaRef.current?.focus()
+                }}
               />
             )
           }