Skip to content

Commit

Permalink
Merge pull request #52374 from Krishna2323/krishna2323/issue/51416
Browse files Browse the repository at this point in the history
fix: Search - Workspace switcher resets to Expensify after manually searching via search input.
  • Loading branch information
lakchote authored Nov 29, 2024
2 parents eddc533 + 8ab7eb2 commit 124a444
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/components/Search/SearchPageHeaderInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ function SearchPageHeaderInput({queryJSON, children}: SearchPageHeaderInputProps
return;
}

if (queryJSON.policyID) {
userQueryJSON.policyID = queryJSON.policyID;
}

const standardizedQuery = SearchQueryUtils.traverseAndUpdatedQuery(userQueryJSON, SearchQueryUtils.getUpdatedAmountValue);
const query = SearchQueryUtils.buildSearchQueryString(standardizedQuery);

Expand All @@ -136,7 +140,7 @@ function SearchPageHeaderInput({queryJSON, children}: SearchPageHeaderInputProps
setIsAutocompleteListVisible(false);
}
},
[autocompleteSubstitutions, originalInputQuery],
[autocompleteSubstitutions, originalInputQuery, queryJSON.policyID],
);

const onListItemPress = (item: OptionData | SearchQueryItem) => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {SearchQueryString} from '@components/Search/types';
import {isSearchQueryItem} from '@components/SelectionList/Search/SearchQueryListItem';
import type {SearchQueryItem} from '@components/SelectionList/Search/SearchQueryListItem';
import type {SelectionListHandle} from '@components/SelectionList/types';
import useActiveWorkspace from '@hooks/useActiveWorkspace';
import useDebouncedState from '@hooks/useDebouncedState';
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -79,6 +80,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret}: SearchRouterProps)
const [recentSearches, recentSearchesMetadata] = useOnyx(ONYXKEYS.RECENT_SEARCHES);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const [autocompleteSubstitutions, setAutocompleteSubstitutions] = useState<SubstitutionMap>({});
const {activeWorkspaceID} = useActiveWorkspace();

const personalDetails = usePersonalDetails();
const [reports = {}] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
Expand Down Expand Up @@ -238,7 +240,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret}: SearchRouterProps)
if (!queryJSON) {
return;
}

queryJSON.policyID = activeWorkspaceID;
onRouterClose();

const standardizedQuery = SearchQueryUtils.traverseAndUpdatedQuery(queryJSON, SearchQueryUtils.getUpdatedAmountValue);
Expand All @@ -248,7 +250,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret}: SearchRouterProps)
setTextInputValue('');
setAutocompleteQueryValue('');
},
[autocompleteSubstitutions, onRouterClose, setTextInputValue],
[autocompleteSubstitutions, onRouterClose, setTextInputValue, activeWorkspaceID],
);

const onListItemPress = (item: OptionData | SearchQueryItem) => {
Expand Down

0 comments on commit 124a444

Please sign in to comment.