An ATproto social media client -- with an independent Appview.
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Reliably focus keyboard on Android (#4427)

authored by

dan and committed by
GitHub
a2d1cf68 5f63b8d4

+25 -7
+25 -7
src/view/com/composer/Composer.tsx
··· 405 405 // Backup focus on android, if the keyboard *still* refuses to show 406 406 useEffect(() => { 407 407 if (!isAndroid) return 408 - if (isModalReady) { 409 - setTimeout(() => { 410 - if (!Keyboard.isVisible()) { 411 - textInput.current?.blur() 412 - textInput.current?.focus() 413 - } 414 - }, 300) 408 + if (!isModalReady) return 409 + 410 + function tryFocus() { 411 + if (!Keyboard.isVisible()) { 412 + textInput.current?.blur() 413 + textInput.current?.focus() 414 + } 415 + } 416 + 417 + tryFocus() 418 + // Retry with enough gap to avoid interrupting the previous attempt. 419 + // Unfortunately we don't know which attempt will succeed. 420 + const retryInterval = setInterval(tryFocus, 500) 421 + 422 + function stopTrying() { 423 + clearInterval(retryInterval) 424 + } 425 + 426 + // Deactivate this fallback as soon as anything happens. 427 + const sub1 = Keyboard.addListener('keyboardDidShow', stopTrying) 428 + const sub2 = Keyboard.addListener('keyboardDidHide', stopTrying) 429 + return () => { 430 + clearInterval(retryInterval) 431 + sub1.remove() 432 + sub2.remove() 415 433 } 416 434 }, [isModalReady]) 417 435