use a timeout to focus the composer input (#4370)
* use a timeout to focus the composer input * scope to just android * scope useEffect to just android as well * oops * cleanup
This commit is contained in:
		
							parent
							
								
									deea2f3839
								
							
						
					
					
						commit
						afbcac3ff3
					
				
					 1 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -154,6 +154,13 @@ export const ComposePost = observer(function ComposePost({
 | 
			
		|||
  const [extGif, setExtGif] = useState<Gif>()
 | 
			
		||||
  const [labels, setLabels] = useState<string[]>([])
 | 
			
		||||
  const [threadgate, setThreadgate] = useState<ThreadgateSetting[]>([])
 | 
			
		||||
 | 
			
		||||
  React.useEffect(() => {
 | 
			
		||||
    if (!isAndroid) return
 | 
			
		||||
    const id = setTimeout(() => textInput.current?.focus(), 100)
 | 
			
		||||
    return () => clearTimeout(id)
 | 
			
		||||
  }, [])
 | 
			
		||||
 | 
			
		||||
  const gallery = useMemo(
 | 
			
		||||
    () => new GalleryModel(initImageUris),
 | 
			
		||||
    [initImageUris],
 | 
			
		||||
| 
						 | 
				
			
			@ -517,7 +524,7 @@ export const ComposePost = observer(function ComposePost({
 | 
			
		|||
                ref={textInput}
 | 
			
		||||
                richtext={richtext}
 | 
			
		||||
                placeholder={selectTextInputPlaceholder}
 | 
			
		||||
                autoFocus={true}
 | 
			
		||||
                autoFocus={!isAndroid}
 | 
			
		||||
                setRichText={setRichText}
 | 
			
		||||
                onPhotoPasted={onPhotoPasted}
 | 
			
		||||
                onPressPublish={onPressPublish}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue