Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useNavigation} from '@react-navigation/native';
import {useIsFocused, useNavigation} from '@react-navigation/native';
import type {StackNavigationProp} from '@react-navigation/stack';
import React, {useCallback, useEffect, useRef, useState} from 'react';
import {View} from 'react-native';
Expand All @@ -21,6 +21,7 @@ import * as SearchActions from '@libs/actions/Search';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import Log from '@libs/Log';
import memoize from '@libs/memoize';
import isSearchTopmostCentralPane from '@libs/Navigation/isSearchTopmostCentralPane';
import * as ReportUtils from '@libs/ReportUtils';
import * as SearchUtils from '@libs/SearchUtils';
import Navigation from '@navigation/Navigation';
Expand Down Expand Up @@ -90,6 +91,7 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
const styles = useThemeStyles();
const {isSmallScreenWidth, isLargeScreenWidth} = useResponsiveLayout();
const navigation = useNavigation<StackNavigationProp<AuthScreensParamList>>();
const isFocused = useIsFocused();
const lastSearchResultsRef = useRef<OnyxEntry<SearchResults>>();
const {setCurrentSearchHash, setSelectedTransactions, selectedTransactions, clearSelectedTransactions, setShouldShowStatusBarLoading, lastSearchType, setLastSearchType} =
useSearchContext();
Expand Down Expand Up @@ -246,6 +248,17 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr
turnOffMobileSelectionMode();
}, [isSearchResultsEmpty, prevIsSearchResultEmpty]);

useEffect(
() => () => {
if (isSearchTopmostCentralPane()) {
return;
}
clearSelectedTransactions();
turnOffMobileSelectionMode();
},
[isFocused, clearSelectedTransactions],
);

if (shouldShowLoadingState) {
return (
<SearchRowSkeleton
Expand Down