Skip to content

Commit ea0773d

Browse files
feat(mobile): the folded Duo opens search from a search tab below the tab bar
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 2c592a1 commit ea0773d

2 files changed

Lines changed: 49 additions & 16 deletions

File tree

‎apps/mobile/src/features/workspace/WorkspaceNativeTabs.ios.tsx‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ import { NativeWorkspaceTabActivityContext } from "../../native/v5-workspace-con
2424
import { useCompactWorkspaceTabs, useSystemWorkspaceTabBar } from "./useSystemWorkspaceTabBar";
2525
import { useControlTheme } from "../../components/ui/useControlTheme";
2626
import { useDeviceType } from "../../native/native-layout-metrics";
27+
import { dispatchHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
2728
import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
2829
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
2930

3031
const PULL_REQUEST_ICON = require("../../../assets/icons/pull-request.png");
32+
const SEARCH_SLOT = "search";
3133

3234
/** Retain each native controller tree; removing its root can leave RNS's stack empty. */
3335
function RetainedWorkspaceTab(props: {
@@ -76,6 +78,15 @@ export function WorkspaceNativeTabs(props: {
7678
const { width } = useWindowDimensions();
7779
const { colors } = useControlTheme();
7880
const selectedTab = workspace.state.selectedTab;
81+
const searchTab = deviceType === "duo-folded";
82+
const openSearch = () => {
83+
if (workspace.settingsOpen) navigation.goBack();
84+
if (workspace.settingsOpen || !workspaceUsesColumns(selectedTab)) {
85+
props.onSelect();
86+
workspace.dispatch({ type: "select", tab: "threads" });
87+
requestAnimationFrame(() => dispatchHardwareKeyboardCommand("focusSearch"));
88+
} else dispatchHardwareKeyboardCommand("focusSearch");
89+
};
7990
const selectedSlot = workspace.settingsOpen ? -1 : primaryTabs.indexOf(selectedTab);
8091
const request = useMemo(
8192
() => ({
@@ -98,6 +109,10 @@ export function WorkspaceNativeTabs(props: {
98109
onTabSelectionPrevented={({
99110
nativeEvent,
100111
}: NativeSyntheticEvent<TabSelectionPreventedEvent>) => {
112+
if (nativeEvent.preventedScreenKey === SEARCH_SLOT) {
113+
openSearch();
114+
return;
115+
}
101116
if (nativeEvent.preventedScreenKey === "settings") {
102117
navigation.navigate("SettingsSheet", {
103118
screen: "SettingsContent",
@@ -113,6 +128,10 @@ export function WorkspaceNativeTabs(props: {
113128
onTabSelected={({ nativeEvent }: NativeSyntheticEvent<TabSelectedEvent>) => {
114129
setProvenance(nativeEvent.provenance);
115130
if (nativeEvent.actionOrigin === "programmatic-js") return;
131+
if (nativeEvent.selectedScreenKey === SEARCH_SLOT) {
132+
openSearch();
133+
return;
134+
}
116135
const tab = workspaceTabForNativeSlot(primaryTabs, nativeEvent.selectedScreenKey);
117136
// UIKit sends reselects here even when preventNativeSelection is enabled.
118137
if (tab === "settings") {
@@ -162,6 +181,24 @@ export function WorkspaceNativeTabs(props: {
162181
</Tabs.Screen>
163182
);
164183
})}
184+
{searchTab ? (
185+
// UIKit sets a search tab apart below the others, like Photos. It never becomes
186+
// selected: pressing it opens the current list's own search.
187+
<Tabs.Screen
188+
key={SEARCH_SLOT}
189+
screenKey={SEARCH_SLOT}
190+
title=""
191+
tabBarItemAccessibilityLabel="Search"
192+
preventNativeSelection
193+
ios={{
194+
role: "search",
195+
systemItem: "search",
196+
automaticallyActivatesSearch: true,
197+
}}
198+
>
199+
<View />
200+
</Tabs.Screen>
201+
) : null}
165202
</Tabs.Host>
166203
{(deviceType === "pad" ||
167204
compactTabs ||

‎apps/mobile/src/features/workspace/WorkspaceToolbar.ios.tsx‎

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,17 @@ export function WorkspaceToolbar(props: {
121121
separateBackground
122122
/>
123123
) : null;
124-
const searchButton = foldedSearch ? (
125-
<Toolbar.Button
126-
identifier="workspace-search"
127-
accessibilityLabel={
128-
searchVisible
129-
? "Close search"
130-
: selectedTab === "pullRequests"
131-
? "Search pull requests"
132-
: "Search threads"
133-
}
134-
icon={searchVisible ? "xmark" : "magnifyingglass"}
135-
onPress={searchVisible ? () => searchRef.current?.cancelSearch() : focusSearch}
136-
separateBackground
137-
/>
138-
) : null;
124+
// The folded Duo opens search from its tab bar's search tab; this button only closes it.
125+
const searchButton =
126+
foldedSearch && searchVisible ? (
127+
<Toolbar.Button
128+
identifier="workspace-search"
129+
accessibilityLabel="Close search"
130+
icon="xmark"
131+
onPress={() => searchRef.current?.cancelSearch()}
132+
separateBackground
133+
/>
134+
) : null;
139135
return (
140136
<>
141137
<NativeStackScreenOptions
@@ -180,7 +176,7 @@ export function WorkspaceToolbar(props: {
180176
{/* UIKit lays trailing items out from the edge inward. */}
181177
<Toolbar placement="right">
182178
{searchButton}
183-
{nativeToolbarCompose && foldedSearch ? <Toolbar.Spacer width={8} /> : null}
179+
{nativeToolbarCompose && searchButton ? <Toolbar.Spacer width={8} /> : null}
184180
{composeButton}
185181
{selectedTab !== "threads" ||
186182
isDuoDevice(deviceType) ||

0 commit comments

Comments
 (0)