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 | ||||
|   } = 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: "", | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user