diff --git a/src/ROUTES.ts b/src/ROUTES.ts index dadbf88f20b2..51d05870da2e 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -35,7 +35,7 @@ const ROUTES = { SEARCH_CENTRAL_PANE: { route: 'search', - getRoute: ({query}: {query: SearchQueryString}) => `search?q=${encodeURIComponent(query)}` as const, + getRoute: ({query, name}: {query: SearchQueryString; name?: string}) => `search?q=${encodeURIComponent(query)}${name ? `&name=${name}` : ''}` as const, }, SEARCH_SAVED_SEARCH_RENAME: { route: 'search/saved-search/rename', diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 39cc50affaa7..39053de521db 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -68,6 +68,7 @@ type CentralPaneScreensParamList = { [SCREENS.SEARCH.CENTRAL_PANE]: { q: SearchQueryString; + name?: string; }; [SCREENS.SETTINGS.SAVE_THE_WORLD]: undefined; [SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: undefined; diff --git a/src/pages/Search/SavedSearchRenamePage.tsx b/src/pages/Search/SavedSearchRenamePage.tsx index 2b227e581ac4..9e4d6122ea4d 100644 --- a/src/pages/Search/SavedSearchRenamePage.tsx +++ b/src/pages/Search/SavedSearchRenamePage.tsx @@ -28,6 +28,7 @@ function SavedSearchRenamePage({route}: {route: {params: {q: string; name: strin Navigation.navigate( ROUTES.SEARCH_CENTRAL_PANE.getRoute({ query: q, + name: newName, }), ); }; diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 7095413398b8..684d45df5a34 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -28,6 +28,7 @@ function SearchPageBottomTab() { const [selectionMode] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE); const searchParams = activeCentralPaneRoute?.params as AuthScreensParamList[typeof SCREENS.SEARCH.CENTRAL_PANE]; const parsedQuery = SearchUtils.buildSearchQueryJSON(searchParams?.q); + const searchName = searchParams?.name; const policyIDFromSearchQuery = parsedQuery && SearchUtils.getPolicyIDFromSearchQuery(parsedQuery); const isActiveCentralPaneRoute = activeCentralPaneRoute?.name === SCREENS.SEARCH.CENTRAL_PANE; const queryJSON = isActiveCentralPaneRoute ? parsedQuery : undefined; @@ -55,7 +56,10 @@ function SearchPageBottomTab() { shouldDisplaySearchRouter={shouldUseNarrowLayout} isCustomSearchQuery={shouldUseNarrowLayout && !SearchUtils.isCannedSearchQuery(queryJSON)} /> - + ) : ( { SearchActions.clearAllFilters(); - Navigation.navigate(ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: item?.query ?? ''})); + Navigation.navigate(ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: item?.query ?? '', name: item?.name})); }, rightComponent: , styles: [styles.alignItemsCenter], @@ -202,7 +203,7 @@ function SearchTypeMenu({queryJSON}: SearchTypeMenuProps) { const activeItemIndex = isCannedQuery ? typeMenuItems.findIndex((item) => item.type === type) : -1; if (shouldUseNarrowLayout) { - const title = isCannedQuery ? undefined : SearchUtils.getSearchHeaderTitle(queryJSON, personalDetails, cardList, reports, taxRates); + const title = searchName ?? (isCannedQuery ? undefined : SearchUtils.getSearchHeaderTitle(queryJSON, personalDetails, cardList, reports, taxRates)); return (