Skip to content

Commit bd654f7

Browse files
shivamhwpclaude
andcommitted
fix(mobile): re-place the Android picker when the screen resizes
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent c76da80 commit bd654f7

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎apps/mobile/src/features/threads/ComposerPopoverAnchor.android.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export function ComposerPopoverAnchor(props: { readonly children: ReactNode }) {
5050
);
5151
});
5252

53-
useEffect(() => () => host?.setContent(null), [host]);
53+
const setHostContent = host?.setContent;
54+
useEffect(() => () => setHostContent?.(null), [setHostContent]);
5455

5556
if (host === null) {
5657
return <View className="absolute inset-x-0 bottom-full z-10 mb-2">{props.children}</View>;

‎apps/mobile/src/features/threads/ComposerPopoverHost.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { View, type ViewInstance } from "react-native";
55
type ComposerPopoverHostValue = {
66
readonly hostRef: RefObject<ViewInstance | null>;
77
readonly setContent: (content: ReactNode) => void;
8+
/** Changes when the host resizes, which moves the bottom-anchored composer. */
9+
readonly layoutVersion: number;
810
};
911

1012
const ComposerPopoverHostContext = createContext<ComposerPopoverHostValue | null>(null);
@@ -22,11 +24,18 @@ export function useComposerPopoverHost() {
2224
export function ComposerPopoverHost(props: { readonly children: ReactNode }) {
2325
const hostRef = useRef<ViewInstance>(null);
2426
const [content, setContent] = useState<ReactNode>(null);
25-
const value = useMemo(() => ({ hostRef, setContent }), []);
27+
const [layoutVersion, setLayoutVersion] = useState(0);
28+
const value = useMemo(() => ({ hostRef, setContent, layoutVersion }), [layoutVersion]);
2629

2730
return (
2831
<ComposerPopoverHostContext.Provider value={value}>
29-
<View ref={hostRef} collapsable={false} pointerEvents="box-none" className="absolute inset-0">
32+
<View
33+
ref={hostRef}
34+
collapsable={false}
35+
pointerEvents="box-none"
36+
className="absolute inset-0"
37+
onLayout={() => setLayoutVersion((version) => version + 1)}
38+
>
3039
{props.children}
3140
{content}
3241
</View>

0 commit comments

Comments
 (0)