diff --git a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx index 62d1bce115..60f44a4cc4 100644 --- a/apps/mobile/src/features/threads/ThreadDetailScreen.tsx +++ b/apps/mobile/src/features/threads/ThreadDetailScreen.tsx @@ -19,7 +19,7 @@ import { useHeaderHeight } from "expo-router/build/react-navigation/elements"; import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; import { View, type GestureResponderEvent } from "react-native"; import { Gesture, GestureDetector } from "react-native-gesture-handler"; -import { KeyboardStickyView } from "react-native-keyboard-controller"; +import { KeyboardController, KeyboardStickyView } from "react-native-keyboard-controller"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { runOnJS } from "react-native-reanimated"; @@ -291,16 +291,31 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread return; } lastScrolledAnchorMessageIdRef.current = anchorMessageId; - void scrollMessageToEnd({ animated: true, closeKeyboard: false }).catch(() => { - if ( - selectedThreadKeyRef.current !== targetThreadKey || - lastScrolledAnchorMessageIdRef.current !== anchorMessageId - ) { - return; - } - lastScrolledAnchorMessageIdRef.current = null; - freeze.set(false); - }); + // Wait for the keyboard dismissal (started by blur() on send) to finish + // before scrolling: scrollMessageToEnd freezes keyboard-driven inset + // updates while it runs, and a close event swallowed by that freeze + // leaves the keyboard padding permanently applied — overshooting the + // anchor and leaving a phantom bottom inset once the reply streams in. + void KeyboardController.dismiss() + .then(() => { + if ( + selectedThreadKeyRef.current !== targetThreadKey || + lastScrolledAnchorMessageIdRef.current !== anchorMessageId + ) { + return; + } + return scrollMessageToEnd({ animated: true, closeKeyboard: false }); + }) + .catch(() => { + if ( + selectedThreadKeyRef.current !== targetThreadKey || + lastScrolledAnchorMessageIdRef.current !== anchorMessageId + ) { + return; + } + lastScrolledAnchorMessageIdRef.current = null; + freeze.set(false); + }); }); return () => cancelAnimationFrame(frame); }, [ diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsx index a82e7c49cc..324fe96134 100644 --- a/apps/mobile/src/features/threads/ThreadFeed.tsx +++ b/apps/mobile/src/features/threads/ThreadFeed.tsx @@ -1456,6 +1456,10 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) { ref={props.listRef} key={props.threadId} style={{ flex: 1 }} + // RN 0.81+ drops touches inside the contentInset area + // (facebook/react-native#54123); the anchored end space after a send + // is pure inset, so without this the blank region can't be scrolled. + applyWorkaroundForContentInsetHitTestBug automaticallyAdjustsScrollIndicatorInsets={false} scrollIndicatorInsets={{ top: topContentInset, bottom: 0 }} {...(anchoredEndSpace ? { anchoredEndSpace } : {})}