@@ -5,7 +5,12 @@ import {
55} from "./navigation-tabs" ;
66import { useCallback , useLayoutEffect , useMemo , useRef , useState , type ReactNode } from "react" ;
77import { View , useWindowDimensions , type NativeSyntheticEvent } from "react-native" ;
8- import { Tabs , type TabSelectedEvent , type TabSelectionRejectedEvent } from "react-native-screens" ;
8+ import {
9+ Tabs ,
10+ type TabSelectedEvent ,
11+ type TabSelectionPreventedEvent ,
12+ type TabSelectionRejectedEvent ,
13+ } from "react-native-screens" ;
914
1015import { WorkspaceTabsContext , useWorkspaceTabs } from "./WorkspaceTabsContext" ;
1116import {
@@ -26,6 +31,7 @@ import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
2631import { useSelectWorkspaceTab } from "./useSelectWorkspaceTab" ;
2732
2833const PULL_REQUEST_ICON = require ( "../../../assets/icons/pull-request.png" ) ;
34+ const SEARCH_SLOT = "search" ;
2935
3036/** Retain each native controller tree; removing its root can leave RNS's stack empty. */
3137function RetainedWorkspaceTab ( props : {
@@ -93,6 +99,17 @@ export function WorkspaceNativeTabs(props: {
9399 const { colors } = useControlTheme ( ) ;
94100 const selectedTab = workspace . state . selectedTab ;
95101 const selectedSlot = workspace . settingsOpen ? - 1 : primaryTabs . indexOf ( selectedTab ) ;
102+ // The folded Duo opens list search from a search tab UIKit sets apart below the others.
103+ const searchTab = deviceType === "duo-folded" ;
104+ // Searching is list state: the list's toolbar mounts its field and focuses it.
105+ const openSearch = ( ) => {
106+ const tab =
107+ ! workspace . settingsOpen && workspaceUsesColumns ( selectedTab ) ? selectedTab : "threads" ;
108+ // Back on the tab's list first: folded, a chat open on top would hide the field.
109+ selectTab ( tab ) ;
110+ workspace . dispatch ( { type : "scroll" , tab, offset : workspace . getScrollOffset ( tab ) } ) ;
111+ workspace . dispatch ( { type : "search" , tab } ) ;
112+ } ;
96113 const request = useMemo (
97114 ( ) => ( {
98115 selectedScreenKey :
@@ -116,9 +133,19 @@ export function WorkspaceNativeTabs(props: {
116133 } : NativeSyntheticEvent < TabSelectionRejectedEvent > ) =>
117134 setProvenance ( nativeEvent . provenance )
118135 }
136+ onTabSelectionPrevented = { ( {
137+ nativeEvent,
138+ } : NativeSyntheticEvent < TabSelectionPreventedEvent > ) => {
139+ if ( nativeEvent . preventedScreenKey === SEARCH_SLOT ) openSearch ( ) ;
140+ } }
119141 onTabSelected = { ( { nativeEvent } : NativeSyntheticEvent < TabSelectedEvent > ) => {
120142 setProvenance ( nativeEvent . provenance ) ;
121143 if ( nativeEvent . actionOrigin === "programmatic-js" ) return ;
144+ // UIKit reports reselecting a tab here even when its selection is prevented.
145+ if ( nativeEvent . selectedScreenKey === SEARCH_SLOT ) {
146+ openSearch ( ) ;
147+ return ;
148+ }
122149 const tab = workspaceTabForNativeSlot ( primaryTabs , nativeEvent . selectedScreenKey ) ;
123150 if ( tab ) selectTab ( tab ) ;
124151 } }
@@ -156,6 +183,24 @@ export function WorkspaceNativeTabs(props: {
156183 </ Tabs . Screen >
157184 ) ;
158185 } ) }
186+ { searchTab ? (
187+ // It never becomes the selected tab; pressing it opens the current list's search.
188+ < Tabs . Screen
189+ key = { SEARCH_SLOT }
190+ screenKey = { SEARCH_SLOT }
191+ title = ""
192+ tabBarItemAccessibilityLabel = "Search"
193+ preventNativeSelection
194+ ios = { {
195+ role : "search" ,
196+ systemItem : "search" ,
197+ // iOS 27 only sets the search tab apart while it activates search.
198+ automaticallyActivatesSearch : true ,
199+ } }
200+ >
201+ < View />
202+ </ Tabs . Screen >
203+ ) : null }
159204 </ Tabs . Host >
160205 { ( deviceType === "pad" ||
161206 compactTabs ||
0 commit comments