Skip to content

Commit

Permalink
Merge pull request #46797 from dominictb/fix/46374-selection-mode
Browse files Browse the repository at this point in the history
fix: turn off selection mode if search result become empty
  • Loading branch information
NikkiWines authored Aug 7, 2024
2 parents 2c60fc9 + 6eb5000 commit ba39514
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SelectionListWithModal from '@components/SelectionListWithModal';
import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePrevious from '@hooks/usePrevious';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {turnOffMobileSelectionMode, turnOnMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
Expand Down Expand Up @@ -177,6 +178,16 @@ function Search({queryJSON, policyIDs, isCustomQuery}: SearchProps) {
const shouldShowLoadingState = !isOffline && !isDataLoaded;
const shouldShowLoadingMoreItems = !shouldShowLoadingState && searchResults?.search?.isLoading && searchResults?.search?.offset > 0;

const isSearchResultsEmpty = !searchResults || SearchUtils.isSearchResultsEmpty(searchResults);
const prevIsSearchResultEmpty = usePrevious(isSearchResultsEmpty);

useEffect(() => {
if (!isSearchResultsEmpty || prevIsSearchResultEmpty) {
return;
}
turnOffMobileSelectionMode();
}, [isSearchResultsEmpty, prevIsSearchResultEmpty]);

const toggleTransaction = (item: TransactionListItemType | ReportListItemType) => {
if (SearchUtils.isTransactionListItemType(item)) {
if (!item.keyForList) {
Expand Down

0 comments on commit ba39514

Please sign in to comment.