refactor: Improve textarea focus behavior in PlaygroundForm component

This commit is contained in:
n4ze3m 2024-08-07 22:14:49 +05:30
parent f6d7020fe0
commit 8bbb3c14f8

View File

@ -39,15 +39,26 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
selectedKnowledge
} = useMessageOption()
const isMobile = () => {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
)
}
const textAreaFocus = () => {
if (textareaRef.current) {
if (
textareaRef.current.selectionStart === textareaRef.current.selectionEnd
) {
textareaRef.current.focus()
if (!isMobile()) {
textareaRef.current.focus()
} else {
textareaRef.current.blur()
}
}
}
}
const form = useForm({
initialValues: {
message: "",