@@ -8,7 +8,6 @@ import SearchTableHeader from '@components/SelectionList/SearchTableHeader';
88import type { ReportActionListItemType , SearchListItem , SelectionListHandle , TransactionGroupListItemType , TransactionListItemType } from '@components/SelectionList/types' ;
99import SearchRowSkeleton from '@components/Skeletons/SearchRowSkeleton' ;
1010import useLocalize from '@hooks/useLocalize' ;
11- import useMobileSelectionMode from '@hooks/useMobileSelectionMode' ;
1211import useNetwork from '@hooks/useNetwork' ;
1312import useOnyx from '@hooks/useOnyx' ;
1413import usePrevious from '@hooks/usePrevious' ;
@@ -61,6 +60,7 @@ type SearchProps = {
6160 contentContainerStyle ?: StyleProp < ViewStyle > ;
6261 searchResults ?: SearchResults ;
6362 handleSearch : ( value : SearchParams ) => void ;
63+ isMobileSelectionModeEnabled : boolean ;
6464} ;
6565
6666function mapTransactionItemToSelectedEntry ( item : TransactionListItemType , reportActions : ReportAction [ ] ) : [ string , SelectedTransactionInfo ] {
@@ -136,7 +136,7 @@ function prepareTransactionsList(item: TransactionListItemType, selectedTransact
136136 } ;
137137}
138138
139- function Search ( { queryJSON, searchResults, onSearchListScroll, contentContainerStyle, handleSearch} : SearchProps ) {
139+ function Search ( { queryJSON, searchResults, onSearchListScroll, contentContainerStyle, handleSearch, isMobileSelectionModeEnabled } : SearchProps ) {
140140 const { isOffline} = useNetwork ( ) ;
141141 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
142142 const styles = useThemeStyles ( ) ;
@@ -157,7 +157,6 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
157157 isExportMode,
158158 setExportMode,
159159 } = useSearchContext ( ) ;
160- const selectionMode = useMobileSelectionMode ( ) ;
161160 const [ offset , setOffset ] = useState ( 0 ) ;
162161
163162 const { type, status, sortBy, sortOrder, hash, groupBy} = queryJSON ;
@@ -191,29 +190,29 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
191190 }
192191
193192 const selectedKeys = Object . keys ( selectedTransactions ) . filter ( ( key ) => selectedTransactions [ key ] ) ;
194- if ( selectedKeys . length === 0 && selectionMode && shouldTurnOffSelectionMode ) {
193+ if ( selectedKeys . length === 0 && isMobileSelectionModeEnabled && shouldTurnOffSelectionMode ) {
195194 turnOffMobileSelectionMode ( ) ;
196195 }
197196
198197 // We don't want to run the effect on isFocused change as we only need it to early return when it is false.
199198 // eslint-disable-next-line react-compiler/react-compiler
200199 // eslint-disable-next-line react-hooks/exhaustive-deps
201- } , [ selectedTransactions , selectionMode , shouldTurnOffSelectionMode ] ) ;
200+ } , [ selectedTransactions , isMobileSelectionModeEnabled , shouldTurnOffSelectionMode ] ) ;
202201
203202 useEffect ( ( ) => {
204203 const selectedKeys = Object . keys ( selectedTransactions ) . filter ( ( key ) => selectedTransactions [ key ] ) ;
205204 if ( ! isSmallScreenWidth ) {
206- if ( selectedKeys . length === 0 && ! ! selectionMode ) {
205+ if ( selectedKeys . length === 0 && isMobileSelectionModeEnabled ) {
207206 turnOffMobileSelectionMode ( ) ;
208207 }
209208 return ;
210209 }
211- if ( selectedKeys . length > 0 && ! selectionMode && ! isSearchResultsEmpty ) {
210+ if ( selectedKeys . length > 0 && ! isMobileSelectionModeEnabled && ! isSearchResultsEmpty ) {
212211 turnOnMobileSelectionMode ( ) ;
213212 }
214213 // eslint-disable-next-line react-compiler/react-compiler
215214 // eslint-disable-next-line react-hooks/exhaustive-deps
216- } , [ isSmallScreenWidth , selectedTransactions , selectionMode ] ) ;
215+ } , [ isSmallScreenWidth , selectedTransactions , isMobileSelectionModeEnabled ] ) ;
217216
218217 useEffect ( ( ) => {
219218 if ( isOffline ) {
@@ -404,7 +403,7 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
404403
405404 const openReport = useCallback (
406405 ( item : SearchListItem ) => {
407- if ( selectionMode ) {
406+ if ( isMobileSelectionModeEnabled ) {
408407 toggleTransaction ( item ) ;
409408 return ;
410409 }
@@ -454,7 +453,7 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
454453
455454 Navigation . navigate ( ROUTES . SEARCH_REPORT . getRoute ( { reportID, backTo} ) ) ;
456455 } ,
457- [ hash , selectionMode , toggleTransaction ] ,
456+ [ hash , isMobileSelectionModeEnabled , toggleTransaction ] ,
458457 ) ;
459458
460459 const onViewableItemsChanged = useCallback (
@@ -476,7 +475,7 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
476475
477476 const isChat = type === CONST . SEARCH . DATA_TYPES . CHAT ;
478477 const isTask = type === CONST . SEARCH . DATA_TYPES . TASK ;
479- const canSelectMultiple = ! isChat && ! isTask && ( ! isSmallScreenWidth || selectionMode === true ) ;
478+ const canSelectMultiple = ! isChat && ! isTask && ( ! isSmallScreenWidth || isMobileSelectionModeEnabled ) ;
480479 const ListItem = getListItem ( type , status , groupBy ) ;
481480 const sortedSelectedData = useMemo (
482481 ( ) =>
@@ -639,6 +638,7 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS
639638 queryJSON = { queryJSON }
640639 onViewableItemsChanged = { onViewableItemsChanged }
641640 onLayout = { onLayout }
641+ isMobileSelectionModeEnabled = { isMobileSelectionModeEnabled }
642642 />
643643 </ SearchScopeProvider >
644644 ) ;
0 commit comments