Skip to content

Commit 202d4a9

Browse files
fix(mobile): the iPhone Duo searches from a field at the bottom of its list
Duo list search lived in the unfolded sidebar's bottom toolbar and moved to a navigation bar button when folded, because UIKit puts a folded column's toolbar in the vertical bar. Every fold re-placed the search controller, which replaces its search field, and a list hidden behind its detail during the fold needed a new controller. The Duo now searches from a full-width field at the bottom of the list in every pose, the glass field the custom workspace toolbar already drew. A fold only changes its width. It rises only once the keyboard reaches it, because UIKit also reports keyboards without height, with a hardware keyboard and around a fold. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 684dfcf commit 202d4a9

6 files changed

Lines changed: 189 additions & 107 deletions

File tree

‎apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ function ColumnScreen(props: {
6868
readonly onDismiss: (routeKey: string) => void;
6969
readonly onAppearance: (type: "willAppear" | "didAppear" | "willDisappear", key: string) => void;
7070
readonly onCompose?: () => void;
71-
readonly covered?: boolean;
7271
readonly navigation: ViewProps["navigation"];
7372
}) {
7473
const { descriptor } = props;
@@ -112,7 +111,6 @@ function ColumnScreen(props: {
112111
canGoBack={!props.primary}
113112
column={props.primary ? "primary" : "detail"}
114113
onCompose={props.onCompose}
115-
covered={props.covered}
116114
/>
117115
<ColumnContent
118116
primary={props.primary}
@@ -252,7 +250,6 @@ function WorkspaceColumns(
252250
selectedPullRequestKey={selectedPullRequestKey}
253251
onDismiss={handleNativeDismiss}
254252
onAppearance={followCollapsedSplit}
255-
covered={!layout.usesSplitView && activeDetailKey !== undefined}
256253
navigation={props.navigation}
257254
/>
258255
</Split.Stack>

‎apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useKeyboardState } from "react-native-keyboard-controller";
55
import { SafeAreaInsetsContext, useSafeAreaInsets } from "react-native-safe-area-context";
66

77
import { CompactBrandTitle } from "../../components/CompactBrandTitle";
8+
import { isDuoDevice } from "../../lib/device-type";
89
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
910
import { NativeStackScreenOptions } from "../../native/StackHeader";
1011
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
@@ -24,7 +25,7 @@ import {
2425
useWorkspaceTabs,
2526
} from "./WorkspaceTabsContext";
2627
import { WorkspaceToolbar } from "./WorkspaceToolbar";
27-
import { WORKSPACE_DOCK, workspaceToolbarHeight } from "./workspace-tabs-state";
28+
import { WORKSPACE_DOCK, WORKSPACE_TOOLBAR, workspaceToolbarHeight } from "./workspace-tabs-state";
2829
import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
2930
import { useSidebarWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
3031

@@ -88,14 +89,16 @@ function WorkspaceRootContent() {
8889
);
8990
const tab = state.tabs[state.selectedTab];
9091
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;
99102
const context = useMemo(() => ({ ...workspace, bottomClearance }), [workspace, bottomClearance]);
100103

101104
return (
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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‎

Lines changed: 103 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,59 @@
11
import { Toolbar } from "../../components/ui/Toolbar";
22
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";
58
import { isDuoDevice } from "../../lib/device-type";
69
import { useDeviceType } from "../../native/native-layout-metrics";
710
import type { SearchBarCommands } from "react-native-screens";
811

12+
import { SymbolView } from "../../components/ui/AppSymbol";
13+
import { GlassSurface } from "../../components/ui/GlassSurface";
914
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
1015
import { NativeStackScreenOptions } from "../../native/StackHeader";
1116
import { NativeWorkspaceTabActivityContext } from "../../native/v5-workspace-context";
1217
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
1318
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
1419
import { useWorkspaceTabs } from "./WorkspaceTabsContext";
20+
import { WorkspaceSearchField } from "./WorkspaceSearchField";
21+
import { WORKSPACE_TOOLBAR } from "./workspace-tabs-state";
1522
import { useSidebarWorkspaceTabs } from "./useSystemWorkspaceTabBar";
1623
import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab";
1724
import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";
1825

1926
// Tabler's git-pull-request geometry, shared with the UIKit tab bar.
2027
const PULL_REQUEST_ICON = require("../../../assets/icons/pull-request.png");
2128

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+
2257
export function WorkspaceToolbar(props: {
2358
readonly onNewTask: () => void;
2459
readonly sidebar?: boolean;
@@ -35,16 +70,16 @@ export function WorkspaceToolbar(props: {
3570
(isDuoDevice(deviceType)
3671
? deviceType === "duo-folded" && workspace.state.selectedTab === "threads"
3772
: 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();
4478
const { isTabActive } = workspace;
4579
const tabActive = use(NativeWorkspaceTabActivityContext)?.active ?? true;
4680
const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout();
4781
const searchRef = useRef<SearchBarCommands>(null);
82+
const fieldRef = useRef<TextInputInstance>(null);
4883
const tab = workspace.state.tabs[workspace.state.selectedTab];
4984
const selectedTab = workspace.state.selectedTab;
5085
const enterSearch = useCallback(() => {
@@ -58,10 +93,25 @@ export function WorkspaceToolbar(props: {
5893
}, [workspace, selectedTab, props.sidebar, panes.primarySidebarVisible, togglePrimarySidebar]);
5994
const focusSearch = useCallback(() => {
6095
if (!workspace.isTabActive(selectedTab)) return false;
96+
if (listSearch) {
97+
fieldRef.current?.focus();
98+
return true;
99+
}
61100
if (!NATIVE_LIQUID_GLASS_SUPPORTED) enterSearch();
62101
searchRef.current?.focus();
63102
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+
);
65115
useHardwareKeyboardCommand("focusSearch", focusSearch);
66116
const restoreSearch = useCallback(() => {
67117
if (isTabActive(selectedTab) && tab.searchMode !== "resting")
@@ -86,30 +136,20 @@ export function WorkspaceToolbar(props: {
86136
// Liquid Glass keeps search mounted as UIKit's own header button, which
87137
// morphs into the field; swapping a stacked bar in and out cannot animate.
88138
headerSearchBarOptions:
89-
NATIVE_LIQUID_GLASS_SUPPORTED || tab.searchMode !== "resting"
139+
!listSearch && (NATIVE_LIQUID_GLASS_SUPPORTED || tab.searchMode !== "resting")
90140
? {
91141
ref: searchRef,
92142
autoFocus: tab.searchMode === "active",
93143
autoCapitalize: "none",
94144
hideNavigationBar: false,
95145
hideWhenScrolling: false,
96146
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,
106149
placeholder:
107150
selectedTab === "pullRequests" ? "Search pull requests" : "Search threads",
108151
cancelButtonText: "✕",
109-
onFocus: () =>
110-
tab.searchMode === "resting"
111-
? enterSearch()
112-
: workspace.dispatch({ type: "search", tab: selectedTab }),
152+
onFocus: searchFocused,
113153
onBlur: () => workspace.dispatch({ type: "expand", tab: selectedTab }),
114154
onSearchButtonPress: () => searchRef.current?.blur(),
115155
onChangeText: ({ nativeEvent }) =>
@@ -118,10 +158,7 @@ export function WorkspaceToolbar(props: {
118158
query: nativeEvent.text,
119159
tab: selectedTab,
120160
}),
121-
onCancelButtonPress: () => {
122-
workspace.recordScrollOffset(selectedTab, tab.searchEntryOffset);
123-
workspace.dispatch({ type: "cancel", tab: selectedTab });
124-
},
161+
onCancelButtonPress: cancelSearch,
125162
}
126163
: undefined,
127164
}}
@@ -168,7 +205,6 @@ export function WorkspaceToolbar(props: {
168205
/>
169206
) : null}
170207
{nativeToolbarCompose ? <Toolbar.Spacer flexible /> : null}
171-
{toolbarSearch ? <Toolbar.SearchBarSlot /> : null}
172208
{nativeToolbarCompose ? (
173209
<Toolbar.Button
174210
identifier="workspace-compose"
@@ -179,6 +215,45 @@ export function WorkspaceToolbar(props: {
179215
/>
180216
) : null}
181217
</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}
182257
</>
183258
);
184259
}

0 commit comments

Comments
 (0)