@devries-cameron20 / t3code Mirror · read-only / commits / 9fa551ac3f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 19:30 UTC

fix(mobile): the iPhone Duo searches from a field at the bottom of its list (#23145)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 21, 2026 at 17:58 UTC 9fa551ac3fcf688a42654039545b2dd0d2ddb3e7
8 files changed +221 -115
apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
-3
@@ -73,7 +73,6 @@ function ColumnScreen(props: {
73 readonly onDismiss: (routeKey: string) => void;
74 readonly onAppearance: (type: "willAppear" | "didAppear" | "willDisappear", key: string) => void;
75 readonly onCompose?: () => void;
76 - readonly covered?: boolean;
76 readonly navigation: ViewProps["navigation"];
77 }) {
78 const { descriptor } = props;
@@ -117,7 +116,6 @@ function ColumnScreen(props: {
116 canGoBack={!props.primary}
117 column={props.primary ? "primary" : "detail"}
118 onCompose={props.onCompose}
120 - covered={props.covered}
119 />
120 <ColumnContent
121 primary={props.primary}
@@ -253,7 +251,6 @@ function WorkspaceColumns(
251 selectedPullRequestKey={selectedPullRequestKey}
252 onDismiss={handleNativeDismiss}
253 onAppearance={followCollapsedSplit}
256 - covered={!layout.usesSplitView && activeDetailKey !== undefined}
254 navigation={props.navigation}
255 />
256 </Split.Stack>
apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx
+12 -9
@@ -5,6 +5,7 @@ import { useKeyboardState } from "react-native-keyboard-controller";
5 import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
6
7 import { CompactBrandTitle } from "../../components/CompactBrandTitle";
8 +import { isDuoDevice } from "../../lib/device-type";
9 import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
10 import { NativeStackScreenOptions } from "../../native/StackHeader";
11 import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -24,7 +25,7 @@ import {
25 useWorkspaceTabs,
26 } from "./WorkspaceTabsContext";
27 import { WorkspaceToolbar } from "./WorkspaceToolbar";
27 -import { WORKSPACE_DOCK, workspaceToolbarHeight } from "./workspace-tabs-state";
28 +import { WORKSPACE_DOCK, WORKSPACE_TOOLBAR, workspaceToolbarHeight } from "./workspace-tabs-state";
29 import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
30 import { useSidebarWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
31
@@ -88,14 +89,16 @@ function WorkspaceRootContent() {
89 );
90 const tab = state.tabs[state.selectedTab];
91 const bottomClearance =
91 - Platform.OS === "ios"
92 - ? Math.max(insets.bottom, keyboardHeight) +
93 - (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
94 - ? 16
95 - : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
96 - : keyboardHeight > 0 && tab.searchMode !== "resting"
97 - ? keyboardHeight + 64
98 - : Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
92 + Platform.OS === "ios" && isDuoDevice(deviceType)
93 + ? Math.max(insets.bottom, 12, keyboardHeight + 8) + WORKSPACE_TOOLBAR.height + 16
94 + : Platform.OS === "ios"
95 + ? Math.max(insets.bottom, keyboardHeight) +
96 + (systemTabBar || sidebarTabs || tab.searchMode !== "resting"
97 + ? 16
98 + : WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
99 + : keyboardHeight > 0 && tab.searchMode !== "resting"
100 + ? keyboardHeight + 64
101 + : Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
102 const context = useMemo(() => ({ ...workspace, bottomClearance }), [workspace, bottomClearance]);
103
104 return (
apps/mobile/src/features/workspace/WorkspaceSearchField.tsx new
+60
@@ -0,0 +1,60 @@
1 +import type { Ref } from "react";
2 +import { Keyboard, Pressable, TextInput, View, type TextInputInstance } from "react-native";
3 +import { useResolveClassNames } from "uniwind";
4 +
5 +import { SymbolView } from "../../components/ui/AppSymbol";
6 +import { GlassSurface } from "../../components/ui/GlassSurface";
7 +import { WORKSPACE_TOOLBAR, type WorkspaceTab } from "./workspace-tabs-state";
8 +
9 +export function WorkspaceSearchField({
10 + ref,
11 + ...props
12 +}: {
13 + readonly ref?: Ref<TextInputInstance>;
14 + readonly tab: WorkspaceTab;
15 + readonly query: string;
16 + readonly onChangeQuery: (query: string) => void;
17 + readonly onFocus: () => void;
18 + readonly onBlur?: () => void;
19 + readonly onClear: () => void;
20 +}) {
21 + const inputStyle = useResolveClassNames("text-foreground font-sans text-base");
22 + const placeholderStyle = useResolveClassNames("text-foreground-muted");
23 + const label = props.tab === "pullRequests" ? "Search pull requests" : "Search threads";
24 + return (
25 + <GlassSurface
26 + className="min-w-0 flex-1"
27 + style={{ height: WORKSPACE_TOOLBAR.height, borderRadius: WORKSPACE_TOOLBAR.height / 2 }}
28 + >
29 + <View className="flex-1 flex-row items-center pl-4">
30 + <SymbolView name="magnifyingglass" size={20} tintColorClassName="accent-icon-muted" />
31 + <TextInput
32 + ref={ref}
33 + accessibilityLabel={label}
34 + placeholder={label}
35 + placeholderTextColor={placeholderStyle.color}
36 + value={props.query}
37 + onChangeText={props.onChangeQuery}
38 + onFocus={props.onFocus}
39 + onBlur={props.onBlur}
40 + onSubmitEditing={() => Keyboard.dismiss()}
41 + autoCapitalize="none"
42 + autoCorrect={false}
43 + returnKeyType="search"
44 + maxLength={props.tab === "pullRequests" ? 200 : undefined}
45 + style={[inputStyle, { flex: 1, minWidth: 0, paddingHorizontal: 8, paddingVertical: 0 }]}
46 + />
47 + {props.query ? (
48 + <Pressable
49 + accessibilityRole="button"
50 + accessibilityLabel="Clear search"
51 + onPress={props.onClear}
52 + className="h-11 w-11 items-center justify-center"
53 + >
54 + <SymbolView name="xmark.circle.fill" size={18} tintColorClassName="accent-icon-muted" />
55 + </Pressable>
56 + ) : null}
57 + </View>
58 + </GlassSurface>
59 + );
60 +}
apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx
+103 -28
@@ -1,17 +1,24 @@
1 import { Toolbar } from "../../components/ui/Toolbar";
2 import { useFocusEffect, useNavigation } from "@react-navigation/native";
3 -import { use, useCallback, useEffect, useRef } from "react";
4 -import { Platform } from "react-native";
3 +import { use, useCallback, useEffect, useRef, type ReactNode } from "react";
4 +import { Platform, Pressable, type TextInputInstance } from "react-native";
5 +import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller";
6 +import Animated, { useAnimatedStyle } from "react-native-reanimated";
7 +import { useSafeAreaInsets } from "react-native-safe-area-context";
8 import { isDuoDevice } from "../../lib/device-type";
9 import { useDeviceType } from "../../native/native-layout-metrics";
10 import type { SearchBarCommands } from "react-native-screens";
11
12 +import { SymbolView } from "../../components/ui/AppSymbol";
13 +import { GlassSurface } from "../../components/ui/GlassSurface";
14 import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
15 import { NativeStackScreenOptions } from "../../native/StackHeader";
16 import { NativeWorkspaceTabActivityContext } from "../../native/v5-workspace-context";
17 import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
18 import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
19 import { useWorkspaceTabs } from "./WorkspaceTabsContext";
20 +import { WorkspaceSearchField } from "./WorkspaceSearchField";
21 +import { WORKSPACE_TOOLBAR } from "./workspace-tabs-state";
22 import { useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
23 import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
24 import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";
@@ -19,6 +26,34 @@ import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";
26 // Tabler's git-pull-request geometry, shared with the UIKit tab bar.
27 const PULL_REQUEST_ICON = require("../../../assets/icons/pull-request.png");
28
29 +/**
30 + * Rises once the keyboard reaches its content. UIKit also reports keyboards without height, with a
31 + * hardware keyboard and around a fold, and those must not move it.
32 + */
33 +function AboveKeyboard(props: { readonly bottom: number; readonly children: ReactNode }) {
34 + const keyboard = useReanimatedKeyboardAnimation();
35 + const { bottom } = props;
36 + const lift = useAnimatedStyle(() => ({
37 + transform: [{ translateY: Math.min(0, keyboard.height.value + bottom - 8) }],
38 + }));
39 + return (
40 + <Animated.View
41 + pointerEvents="box-none"
42 + className="absolute inset-x-0 bottom-0 flex-row items-center"
43 + style={[
44 + {
45 + gap: WORKSPACE_TOOLBAR.gap,
46 + paddingHorizontal: WORKSPACE_TOOLBAR.edge,
47 + paddingBottom: bottom,
48 + },
49 + lift,
50 + ]}
51 + >
52 + {props.children}
53 + </Animated.View>
54 + );
55 +}
56 +
57 export function WorkspaceToolbar(props: {
58 readonly onNewTask: () => void;
59 readonly sidebar?: boolean;
@@ -35,16 +70,16 @@ export function WorkspaceToolbar(props: {
70 (isDuoDevice(deviceType)
71 ? deviceType === "duo-folded" && workspace.state.selectedTab === "threads"
72 : deviceType === "pad");
38 - // The expanded Duo sidebar keeps a full search field in its bottom toolbar. UIKit holds the
39 - // integrated field there, but moves the button form into the detail column's vertical bar.
40 - // Folded, the workspace tab bar owns the bottom of the vertical bar, so search keeps UIKit's
41 - // own placement.
42 - const toolbarSearch =
43 - NATIVE_LIQUID_GLASS_SUPPORTED && deviceType === "duo-unfolded" && props.sidebar === true;
73 + // The Duo searches from a field at the bottom of the list in every pose. UIKit has no such
74 + // placement once the vertical bar holds the toolbar, and re-placing its search controller on
75 + // each fold replaces the search field.
76 + const listSearch = isDuoDevice(deviceType);
77 + const insets = useSafeAreaInsets();
78 const { isTabActive } = workspace;
79 const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
80 const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
81 const searchRef = useRef<SearchBarCommands>(null);
82 + const fieldRef = useRef<TextInputInstance>(null);
83 const tab = workspace.state.tabs[workspace.state.selectedTab];
84 const selectedTab = workspace.state.selectedTab;
85 const enterSearch = useCallback(() => {
@@ -58,10 +93,25 @@ export function WorkspaceToolbar(props: {
93 }, [workspace, selectedTab, props.sidebar, panes.primarySidebarVisible, togglePrimarySidebar]);
94 const focusSearch = useCallback(() => {
95 if (!workspace.isTabActive(selectedTab)) return false;
96 + if (listSearch) {
97 + fieldRef.current?.focus();
98 + return true;
99 + }
100 if (!NATIVE_LIQUID_GLASS_SUPPORTED) enterSearch();
101 searchRef.current?.focus();
102 return true;
64 - }, [workspace, selectedTab, enterSearch]);
103 + }, [workspace, selectedTab, listSearch, enterSearch]);
104 + const cancelSearch = useCallback(() => {
105 + workspace.recordScrollOffset(selectedTab, tab.searchEntryOffset);
106 + workspace.dispatch({ type: "cancel", tab: selectedTab });
107 + }, [workspace, selectedTab, tab.searchEntryOffset]);
108 + const searchFocused = useCallback(
109 + () =>
110 + tab.searchMode === "resting"
111 + ? enterSearch()
112 + : workspace.dispatch({ type: "search", tab: selectedTab }),
113 + [tab.searchMode, enterSearch, workspace, selectedTab],
114 + );
115 useHardwareKeyboardCommand("focusSearch", focusSearch);
116 const restoreSearch = useCallback(() => {
117 if (isTabActive(selectedTab) && tab.searchMode !== "resting")
@@ -86,7 +136,7 @@ export function WorkspaceToolbar(props: {
136 // Liquid Glass keeps search mounted as UIKit's own header button, which
137 // morphs into the field; swapping a stacked bar in and out cannot animate.
138 headerSearchBarOptions:
89 - NATIVE_LIQUID_GLASS_SUPPORTED || tab.searchMode !== "resting"
139 + !listSearch && (NATIVE_LIQUID_GLASS_SUPPORTED || tab.searchMode !== "resting")
140 ? {
141 ref: searchRef,
142 autoFocus: tab.searchMode === "active",
@@ -94,22 +144,12 @@ export function WorkspaceToolbar(props: {
144 hideNavigationBar: false,
145 hideWhenScrolling: false,
146 obscureBackground: false,
97 - placement: toolbarSearch
98 - ? "integrated"
99 - : NATIVE_LIQUID_GLASS_SUPPORTED
100 - ? "integratedButton"
101 - : "stacked",
102 - // Folded, the tab bar owns the bottom of the vertical bar; refusing toolbar
103 - // integration also makes UIKit re-place a visible search in the navigation bar.
104 - allowToolbarIntegration:
105 - NATIVE_LIQUID_GLASS_SUPPORTED && deviceType !== "duo-folded",
147 + placement: NATIVE_LIQUID_GLASS_SUPPORTED ? "integratedButton" : "stacked",
148 + allowToolbarIntegration: NATIVE_LIQUID_GLASS_SUPPORTED,
149 placeholder:
150 selectedTab === "pullRequests" ? "Search pull requests" : "Search threads",
151 cancelButtonText: "✕",
109 - onFocus: () =>
110 - tab.searchMode === "resting"
111 - ? enterSearch()
112 - : workspace.dispatch({ type: "search", tab: selectedTab }),
152 + onFocus: searchFocused,
153 onBlur: () => workspace.dispatch({ type: "expand", tab: selectedTab }),
154 onSearchButtonPress: () => searchRef.current?.blur(),
155 onChangeText: ({ nativeEvent }) =>
@@ -118,10 +158,7 @@ export function WorkspaceToolbar(props: {
158 query: nativeEvent.text,
159 tab: selectedTab,
160 }),
121 - onCancelButtonPress: () => {
122 - workspace.recordScrollOffset(selectedTab, tab.searchEntryOffset);
123 - workspace.dispatch({ type: "cancel", tab: selectedTab });
124 - },
161 + onCancelButtonPress: cancelSearch,
162 }
163 : undefined,
164 }}
@@ -168,7 +205,6 @@ export function WorkspaceToolbar(props: {
205 />
206 ) : null}
207 {nativeToolbarCompose ? <Toolbar.Spacer flexible /> : null}
171 - {toolbarSearch ? <Toolbar.SearchBarSlot /> : null}
208 {nativeToolbarCompose ? (
209 <Toolbar.Button
210 identifier="workspace-compose"
@@ -179,6 +215,45 @@ export function WorkspaceToolbar(props: {
215 />
216 ) : null}
217 </Toolbar>
218 + {listSearch ? (
219 + <AboveKeyboard bottom={Math.max(insets.bottom, 12)}>
220 + <WorkspaceSearchField
221 + ref={fieldRef}
222 + tab={selectedTab}
223 + query={tab.query}
224 + onChangeQuery={(query) =>
225 + workspace.dispatch({ type: "query", query, tab: selectedTab })
226 + }
227 + onFocus={searchFocused}
228 + onBlur={() => workspace.dispatch({ type: "expand", tab: selectedTab })}
229 + onClear={() => {
230 + workspace.dispatch({ type: "query", query: "", tab: selectedTab });
231 + fieldRef.current?.focus();
232 + }}
233 + />
234 + {tab.searchMode === "resting" ? null : (
235 + <GlassSurface
236 + style={{
237 + width: WORKSPACE_TOOLBAR.height,
238 + height: WORKSPACE_TOOLBAR.height,
239 + borderRadius: WORKSPACE_TOOLBAR.height / 2,
240 + }}
241 + >
242 + <Pressable
243 + accessibilityRole="button"
244 + accessibilityLabel="Cancel search"
245 + onPress={() => {
246 + cancelSearch();
247 + fieldRef.current?.blur();
248 + }}
249 + className="flex-1 items-center justify-center"
250 + >
251 + <SymbolView name="xmark" size={20} tintColorClassName="accent-icon" />
252 + </Pressable>
253 + </GlassSurface>
254 + )}
255 + </AboveKeyboard>
256 + ) : null}
257 </>
258 );
259 }
apps/mobile/src/features/workspace/WorkspaceToolbar.tsx
+12 -48
@@ -5,19 +5,18 @@ import {
5 Keyboard,
6 Platform,
7 Pressable,
8 - TextInput,
8 View,
9 useWindowDimensions,
10 type TextInputInstance,
11 } from "react-native";
12 import { KeyboardStickyView, useKeyboardState } from "react-native-keyboard-controller";
13 import { useSafeAreaInsets } from "react-native-safe-area-context";
15 -import { useResolveClassNames } from "uniwind";
14
15 import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
16 import { GlassSurface } from "../../components/ui/GlassSurface";
17 import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
18 import { WorkspaceDock } from "./WorkspaceDock";
19 +import { WorkspaceSearchField } from "./WorkspaceSearchField";
20 import { useWorkspaceTabs } from "./WorkspaceTabsContext";
21 import { WORKSPACE_TOOLBAR, type WorkspaceTab } from "./workspace-tabs-state";
22 import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
@@ -60,8 +59,6 @@ export function WorkspaceToolbar(props: {
59 const edge = width < 360 ? 12 : WORKSPACE_TOOLBAR.edge;
60 const gap = width < 360 ? 6 : WORKSPACE_TOOLBAR.gap;
61 const keyboardVisible = useKeyboardState((state) => state.isVisible);
63 - const inputStyle = useResolveClassNames("text-foreground font-sans text-base");
64 - const placeholderStyle = useResolveClassNames("text-foreground-muted");
62 const focusSearch = useCallback(() => {
63 if (!workspace) return false;
64 const tab = workspace.state.selectedTab;
@@ -126,50 +123,17 @@ export function WorkspaceToolbar(props: {
123 onPress={() => dispatch({ type: "expand" })}
124 />
125 ) : null}
129 - <GlassSurface className="min-w-0 flex-1" style={{ height: 48, borderRadius: 24 }}>
130 - <View className="flex-1 flex-row items-center pl-4">
131 - <SymbolView
132 - name="magnifyingglass"
133 - size={20}
134 - tintColorClassName="accent-icon-muted"
135 - />
136 - <TextInput
137 - ref={input}
138 - accessibilityLabel={`Search ${activeTab.label}`}
139 - placeholder={`Search ${activeTab.label === "PRs" ? "pull requests" : "threads"}`}
140 - placeholderTextColor={placeholderStyle.color}
141 - value={tab.query}
142 - onChangeText={(query) => dispatch({ type: "query", query })}
143 - onFocus={() => dispatch({ type: "search" })}
144 - onSubmitEditing={() => Keyboard.dismiss()}
145 - autoCapitalize="none"
146 - autoCorrect={false}
147 - returnKeyType="search"
148 - maxLength={state.selectedTab === "pullRequests" ? 200 : undefined}
149 - style={[
150 - inputStyle,
151 - { flex: 1, minWidth: 0, paddingHorizontal: 8, paddingVertical: 0 },
152 - ]}
153 - />
154 - {tab.query ? (
155 - <Pressable
156 - accessibilityRole="button"
157 - accessibilityLabel="Clear search"
158 - onPress={() => {
159 - dispatch({ type: "query", query: "" });
160 - focusSearch();
161 - }}
162 - className="h-11 w-11 items-center justify-center"
163 - >
164 - <SymbolView
165 - name="xmark.circle.fill"
166 - size={18}
167 - tintColorClassName="accent-icon-muted"
168 - />
169 - </Pressable>
170 - ) : null}
171 - </View>
172 - </GlassSurface>
126 + <WorkspaceSearchField
127 + ref={input}
128 + tab={state.selectedTab}
129 + query={tab.query}
130 + onChangeQuery={(query) => dispatch({ type: "query", query })}
131 + onFocus={() => dispatch({ type: "search" })}
132 + onClear={() => {
133 + dispatch({ type: "query", query: "" });
134 + focusSearch();
135 + }}
136 + />
137 <ToolbarButton label="Cancel search" icon="xmark" size={48} onPress={cancelSearch} />
138 </View>
139 ) : null}
apps/mobile/src/native/NativeHeaderToolbar.test.tsx
+19 -6
@@ -3,22 +3,34 @@ import { act, createContext, type ReactElement } from "react";
3 import { createRoot, type Root } from "react-dom/client";
4 import { afterEach, expect, it, vi } from "vite-plus/test";
5
6 +type HeaderOptions = {
7 + unstable_headerLeftItems?: () => NativeStackHeaderItem[];
8 + unstable_headerRightItems?: () => NativeStackHeaderItem[];
9 + unstable_headerToolbarItems?: () => NativeStackHeaderItem[];
10 +};
11 +
12 const harness = vi.hoisted(() => ({
13 params: { path: ["first", "guide.pdf"] },
14 + appliedOptions: {} as HeaderOptions,
15 renderedItems: [] as NativeStackHeaderItem[],
16 setOptionsCalls: 0,
17 openedDocuments: [] as string[],
18 }));
19
13 -// Native headers retain the actions materialized when navigation applies options.
20 +// Native headers retain the actions materialized when navigation applies options. Like React
21 +// Navigation, the header renders again only when the options are no longer shallowly equal.
22 vi.mock("@react-navigation/native", () => {
23 const navigation = {
16 - setOptions(options: {
17 - unstable_headerLeftItems?: () => NativeStackHeaderItem[];
18 - unstable_headerRightItems?: () => NativeStackHeaderItem[];
19 - unstable_headerToolbarItems?: () => NativeStackHeaderItem[];
20 - }) {
24 + setOptions(options: HeaderOptions) {
25 harness.setOptionsCalls += 1;
26 + const previous: Record<string, unknown> = harness.appliedOptions;
27 + const next: Record<string, unknown> = { ...previous, ...options };
28 + harness.appliedOptions = next;
29 + if (
30 + Object.keys(next).length === Object.keys(previous).length &&
31 + Object.keys(next).every((key) => next[key] === previous[key])
32 + )
33 + return;
34 harness.renderedItems =
35 options.unstable_headerLeftItems?.() ??
36 options.unstable_headerRightItems?.() ??
@@ -104,6 +116,7 @@ function openRenderedDocument() {
116 afterEach(() => {
117 act(() => root?.unmount());
118 root = null;
119 + harness.appliedOptions = {};
120 harness.renderedItems = [];
121 harness.setOptionsCalls = 0;
122 harness.openedDocuments = [];
apps/mobile/src/native/StackHeader.tsx
+13 -2
@@ -199,8 +199,19 @@ export function NativeStackScreenOptions(props: {
199 return;
200 }
201 lastAppliedOptionsSignatureRef.current = signature;
202 - navigation.setOptions(stableOptions);
203 - }, [navigation, props.optionsVersion, stableOptions, tabActive]);
202 + // React Navigation keeps a screen's descriptor while its options are shallowly equal. The
203 + // stabilized factories keep their identity, so one whose output changed needs a new wrapper
204 + // to reach the header.
205 + optionFunctionWrappersRef.current = new Map();
206 + navigation.setOptions(
207 + stabilizeOptionFunctions(
208 + normalizedOptions,
209 + "options",
210 + latestOptionFunctionsRef.current,
211 + optionFunctionWrappersRef.current,
212 + ) as NativeStackNavigationOptions,
213 + );
214 + }, [navigation, normalizedOptions, props.optionsVersion, stableOptions, tabActive]);
215
216 useEffect(() => {
217 if (!navigation || !props.listeners) {
apps/mobile/src/native/V5StackHeader.ios.tsx
+2 -19
@@ -3,7 +3,7 @@ import type {
3 NativeStackHeaderItemMenu,
4 NativeStackNavigationOptions,
5 } from "@react-navigation/native-stack";
6 -import { isValidElement, useEffect, useRef, useState } from "react";
6 +import { isValidElement, useEffect, useRef } from "react";
7 import { StyleSheet } from "react-native";
8 import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";
9 import { useDeviceType, useNativeLayoutMetrics } from "../native/native-layout-metrics";
@@ -145,8 +145,6 @@ export function V5StackHeader(props: {
145 readonly column?: "primary" | "detail";
146 /** The workspace's compose action, shown as its own group in this column's bar. */
147 readonly onCompose?: () => void;
148 - /** Whether another column covers this one in a collapsed split. */
149 - readonly covered?: boolean;
148 }) {
149 const { options } = props;
150 const theme = useMobileNavigationTheme();
@@ -239,20 +237,6 @@ export function V5StackHeader(props: {
237 ? options.headerTitle({ children: title ?? "", tintColor: options.headerTintColor })
238 : undefined;
239 const searchOptions = options.headerSearchBarOptions;
242 - const searchPlacement = bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic");
243 - // UIKit re-places a visible search controller when its placement changes, but not one whose
244 - // column is covered; that one needs a new controller to place once the column shows again.
245 - // A hidden tab only sees the new placement as it returns, after its detail uncovered the list.
246 - const covered = props.covered === true;
247 - const [search, setSearch] = useState({ placement: searchPlacement, covered, epoch: 0 });
248 - if (search.placement !== searchPlacement || search.covered !== covered)
249 - setSearch({
250 - placement: searchPlacement,
251 - covered,
252 - epoch:
253 - search.epoch +
254 - (search.placement !== searchPlacement && (search.covered || covered) ? 1 : 0),
255 - });
240 const autofocusRef = searchOptions?.ref ?? searchRef;
241 const searchHasFocus = useRef(false);
242 useEffect(() => {
@@ -299,13 +283,12 @@ export function V5StackHeader(props: {
283 searchBar:
284 mailSearch || searchOptions ? (
285 <SearchBar
302 - key={search.epoch}
286 {...searchOptions}
287 ref={searchOptions?.ref ?? searchRef}
288 hideNavigationBar={false}
289 hideWhenScrolling={false}
290 allowToolbarIntegration={searchOptions?.allowToolbarIntegration ?? true}
308 - placement={searchPlacement}
291 + placement={bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic")}
292 placeholder={mailSearch?.placeholder ?? searchOptions?.placeholder ?? "Search"}
293 onFocus={(event) => {
294 searchHasFocus.current = true;