11import { NativeHeaderToolbar , NativeStackScreenOptions } from "../../native/StackHeader" ;
2- import { use , useCallback , useEffect , useRef } from "react" ;
2+ import { use , useCallback , useEffect , useEffectEvent , useRef } from "react" ;
33import { useNavigation , type ParamListBase } from "@react-navigation/native" ;
44import type { NativeStackNavigationProp } from "@react-navigation/native-stack" ;
55import { Platform } from "react-native" ;
@@ -21,14 +21,23 @@ export function HomeHeader(props: HomeHeaderProps) {
2121 const navigation = useNavigation < NativeStackNavigationProp < ParamListBase > > ( ) ;
2222 const { panes, togglePrimarySidebar } = useAdaptiveWorkspaceLayout ( ) ;
2323 const usesNativeMailSearchToolbar = useNativeMailSearchToolbar ( ) ;
24- const isPad = Platform . OS === "ios" && Platform . isPad ;
2524 const primaryColumn = use ( NativePrimaryColumnContext ) ;
2625 const sidebarHeader =
2726 Platform . OS === "ios" &&
2827 primaryColumn !== null &&
2928 ( Platform . isPad || ! usesNativeMailSearchToolbar ) ;
3029 const searchBarRef = useRef < SearchBarCommands > ( null ) ;
3130 const focusAfterReveal = useRef ( false ) ;
31+ const usesDuoWorkspace = Platform . OS === "ios" && ! Platform . isPad && primaryColumn !== null ;
32+ const restoreSearchText = useEffectEvent ( ( ) => {
33+ searchBarRef . current ?. setText ( props . searchQuery ) ;
34+ } ) ;
35+ // UIKit swaps search fields when the Duo header changes modes. Restore the
36+ // current filter without reapplying text on each keystroke.
37+ useEffect ( ( ) => {
38+ if ( usesDuoWorkspace ) restoreSearchText ( ) ;
39+ // oxlint-disable-next-line react/exhaustive-effect-dependencies -- Header mode changes replace the native search field.
40+ } , [ sidebarHeader , usesDuoWorkspace ] ) ;
3241 useEffect (
3342 ( ) =>
3443 navigation . addListener ( "transitionEnd" , ( event ) => {
@@ -93,11 +102,9 @@ export function HomeHeader(props: HomeHeaderProps) {
93102 autoCapitalize : "none" as const ,
94103 hideNavigationBar : false ,
95104 hideWhenScrolling : false ,
96- ...( isPad ? { obscureBackground : false } : { } ) ,
97- // Duo keeps the integrated search presentation while UIKit
98- // moves the header between horizontal and vertical bars.
99- placement : isPad ? ( "stacked" as const ) : ( "integrated" as const ) ,
100- allowToolbarIntegration : ! isPad ,
105+ obscureBackground : false ,
106+ placement : "stacked" as const ,
107+ allowToolbarIntegration : false ,
101108 placeholder : "Search" ,
102109 onCancelButtonPress : ( ) => props . onSearchQueryChange ( "" ) ,
103110 onChangeText : ( event ) => props . onSearchQueryChange ( event . nativeEvent . text ) ,
0 commit comments