From 88589c4f2fa7d04b3afd68366e54c7fc6e7cd50d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 6 Jun 2024 14:25:18 +0300 Subject: [PATCH] keep trying to open keyboard until it's open --- src/view/com/composer/Composer.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index 80890286bc..0b89814501 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -155,10 +155,16 @@ export const ComposePost = observer(function ComposePost({ const [labels, setLabels] = useState([]) const [threadgate, setThreadgate] = useState([]) - React.useEffect(() => { + useEffect(() => { if (!isAndroid) return - const id = setTimeout(() => textInput.current?.focus(), 100) - return () => clearTimeout(id) + const id = setInterval(() => { + if (Keyboard.isVisible()) { + clearInterval(id) + } else { + textInput.current?.focus() + } + }, 50) + return () => clearInterval(id) }, []) const gallery = useMemo( @@ -181,9 +187,7 @@ export const ComposePost = observer(function ComposePost({ const onPressCancel = useCallback(() => { if (graphemeLength > 0 || !gallery.isEmpty || extGif) { closeAllDialogs() - if (Keyboard) { - Keyboard.dismiss() - } + Keyboard.dismiss() discardPromptControl.open() } else { onClose()