Update package.json version and fix text area focus bug
This commit is contained in:
@@ -19,23 +19,21 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
||||
const textareaRef = React.useRef<HTMLTextAreaElement>(null)
|
||||
const inputRef = React.useRef<HTMLInputElement>(null)
|
||||
|
||||
const resetHeight = () => {
|
||||
const textarea = textareaRef.current
|
||||
if (textarea) {
|
||||
textarea.style.height = "auto"
|
||||
const textAreaFocus = () => {
|
||||
if (textareaRef.current) {
|
||||
textareaRef.current.focus()
|
||||
}
|
||||
}
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
message: "",
|
||||
image: ""
|
||||
}
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
React.useEffect(() => {
|
||||
if (textareaRef.current) {
|
||||
textareaRef.current.focus()
|
||||
}
|
||||
textAreaFocus()
|
||||
}, [])
|
||||
|
||||
const onInputChange = async (
|
||||
@@ -85,9 +83,13 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
||||
const { mutateAsync: sendMessage } = useMutation({
|
||||
mutationFn: onSubmit,
|
||||
onSuccess: () => {
|
||||
textAreaFocus()
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["fetchChatHistory"]
|
||||
})
|
||||
},
|
||||
onError: (error) => {
|
||||
textAreaFocus()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -133,11 +135,12 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
||||
}
|
||||
}
|
||||
form.reset()
|
||||
resetHeight()
|
||||
textAreaFocus()
|
||||
await sendMessage({
|
||||
image: value.image,
|
||||
message: value.message.trim()
|
||||
})
|
||||
|
||||
})}
|
||||
className="shrink-0 flex-grow flex flex-col items-center ">
|
||||
<input
|
||||
@@ -179,7 +182,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
||||
}
|
||||
}
|
||||
form.reset()
|
||||
resetHeight()
|
||||
textAreaFocus()
|
||||
await sendMessage({
|
||||
image: value.image,
|
||||
message: value.message.trim()
|
||||
|
||||
@@ -19,10 +19,9 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
|
||||
const inputRef = React.useRef<HTMLInputElement>(null)
|
||||
const { sendWhenEnter, setSendWhenEnter } = useWebUI()
|
||||
|
||||
const resetHeight = () => {
|
||||
const textarea = textareaRef.current
|
||||
if (textarea) {
|
||||
textarea.style.height = "auto"
|
||||
const textAreaFocus = () => {
|
||||
if (textareaRef.current) {
|
||||
textareaRef.current.focus()
|
||||
}
|
||||
}
|
||||
const form = useForm({
|
||||
@@ -64,7 +63,13 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
|
||||
}
|
||||
}, [transcript])
|
||||
const { mutateAsync: sendMessage, isPending: isSending } = useMutation({
|
||||
mutationFn: onSubmit
|
||||
mutationFn: onSubmit,
|
||||
onSuccess: () => {
|
||||
textAreaFocus()
|
||||
},
|
||||
onError: (error) => {
|
||||
textAreaFocus()
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
@@ -109,7 +114,7 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
|
||||
}
|
||||
}
|
||||
form.reset()
|
||||
resetHeight()
|
||||
textAreaFocus()
|
||||
await sendMessage({
|
||||
image: value.image,
|
||||
message: value.message.trim()
|
||||
@@ -155,7 +160,7 @@ export const SidepanelForm = ({ dropedFile }: Props) => {
|
||||
}
|
||||
}
|
||||
form.reset()
|
||||
resetHeight()
|
||||
textAreaFocus()
|
||||
await sendMessage({
|
||||
image: value.image,
|
||||
message: value.message.trim()
|
||||
|
||||
Reference in New Issue
Block a user