refactor: Improve textarea focus behavior in PlaygroundForm component
This commit is contained in:
parent
f6d7020fe0
commit
8bbb3c14f8
@ -39,15 +39,26 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
|
|||||||
selectedKnowledge
|
selectedKnowledge
|
||||||
} = useMessageOption()
|
} = useMessageOption()
|
||||||
|
|
||||||
|
const isMobile = () => {
|
||||||
|
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
||||||
|
navigator.userAgent
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const textAreaFocus = () => {
|
const textAreaFocus = () => {
|
||||||
if (textareaRef.current) {
|
if (textareaRef.current) {
|
||||||
if (
|
if (
|
||||||
textareaRef.current.selectionStart === textareaRef.current.selectionEnd
|
textareaRef.current.selectionStart === textareaRef.current.selectionEnd
|
||||||
) {
|
) {
|
||||||
textareaRef.current.focus()
|
if (!isMobile()) {
|
||||||
|
textareaRef.current.focus()
|
||||||
|
} else {
|
||||||
|
textareaRef.current.blur()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
message: "",
|
message: "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user