From d633d7a021cb35591dbea61175111e1d3c40c3ae Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 24 Sep 2024 17:36:58 -0500 Subject: [PATCH] Fix sticky header --- src/view/screens/Search/Search.tsx | 166 +++++++++++++++-------------- 1 file changed, 87 insertions(+), 79 deletions(-) diff --git a/src/view/screens/Search/Search.tsx b/src/view/screens/Search/Search.tsx index a0dec77880..b487a555a0 100644 --- a/src/view/screens/Search/Search.tsx +++ b/src/view/screens/Search/Search.tsx @@ -453,11 +453,14 @@ function useQueryManager({initialQuery}: {initialQuery: string}) { } let SearchScreenInner = ({ - query: initialQuery, + query, + queryWithParams, + headerHeight, }: { query: string + queryWithParams: string + headerHeight: number }): React.ReactNode => { - const t = useThemeNew() const pal = usePalette('default') const setMinimalShellMode = useSetMinimalShellMode() const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() @@ -465,9 +468,6 @@ let SearchScreenInner = ({ const {isDesktop} = useWebMediaQueries() const [activeTab, setActiveTab] = React.useState(0) const {_} = useLingui() - const {gtMobile} = useBreakpoints() - - const {params, query, queryWithParams} = useQueryManager({initialQuery}) const onPageSelected = React.useCallback( (index: number) => { @@ -517,40 +517,25 @@ let SearchScreenInner = ({ }, [_, query, queryWithParams, activeTab]) return query ? ( - <> - - - - - - - - - ( - - section.title)} {...props} /> - - )} - initialPage={0}> - {sections.map((section, i) => ( - {section.component} - ))} - - + ( + + section.title)} {...props} /> + + )} + initialPage={0}> + {sections.map((section, i) => ( + {section.component} + ))} + ) : hasSession ? ( ) : ( @@ -819,59 +804,78 @@ export function SearchScreen( [selectedProfiles], ) + const {params, query, queryWithParams} = useQueryManager({ + initialQuery: queryParam, + }) + const showFilters = Boolean(query && !showAutocomplete) + const headerHeight = HEADER_HEIGHT + (showFilters ? 40 : 0) + return ( - {!gtMobile && ( - - )} - - {showAutocomplete && ( - + + {!gtMobile && ( + + )} + + {showAutocomplete && ( + + )} + + + {query && !showAutocomplete && ( + + + + + )} @@ -905,7 +909,12 @@ export function SearchScreen( display: showAutocomplete ? 'none' : 'flex', flex: 1, }}> - + ) @@ -1233,7 +1242,6 @@ const styles = StyleSheet.create({ tabBarContainer: { // @ts-ignore web only position: isWeb ? 'sticky' : '', - top: isWeb ? HEADER_HEIGHT : 0, zIndex: 1, }, searchHistoryContainer: {