From eddb2c307875d9e2bc35aa0648075d9edef7ba3c Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 29 Apr 2026 10:37:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(expo):=20=E5=8F=91=E9=80=81=E5=90=8E?= =?UTF-8?q?=E5=BB=B6=E6=97=B6=20refocus=20=E8=81=8A=E5=A4=A9=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 发送会递增 inputResetKey 以 remount TextInput,需在下一帧再 focus 才能延续键盘输入。 Made-with: Cursor --- app-expo/src/app/(main)/conversation/[id].tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app-expo/src/app/(main)/conversation/[id].tsx b/app-expo/src/app/(main)/conversation/[id].tsx index 6bee70e..0faea35 100644 --- a/app-expo/src/app/(main)/conversation/[id].tsx +++ b/app-expo/src/app/(main)/conversation/[id].tsx @@ -1219,6 +1219,17 @@ export default function ConversationScreen() { } }, []); + /** 发送后 `inputResetKey` 会 remount TextInput,需下一帧再 focus 才能延续键盘输入 */ + const scheduleRefocusComposer = useCallback(() => { + InteractionManager.runAfterInteractions(() => { + requestAnimationFrame(() => { + requestAnimationFrame(() => { + textInputRef.current?.focus(); + }); + }); + }); + }, []); + const flattenedData = useMemo( () => flattenMessagesForList(messages ?? []), [messages], @@ -1366,6 +1377,7 @@ export default function ConversationScreen() { pendingTextSendRef.current = text; setInput(''); setInputResetKey((k) => k + 1); + scheduleRefocusComposer(); clearConnectingSendTimeout(); connectingSendTimeoutRef.current = setTimeout(() => { connectingSendTimeoutRef.current = null; @@ -1379,6 +1391,7 @@ export default function ConversationScreen() { sendText(text); setInput(''); setInputResetKey((k) => k + 1); + scheduleRefocusComposer(); }; /** 仅完全断开时禁用发送/语音;连接中可点发送(排队) */