diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index a13b816fd8b84..7e0792bb68905 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -40,6 +40,7 @@ type SearchProps = { queryJSON: SearchQueryJSON; onSearchListScroll?: (event: NativeSyntheticEvent) => void; contentContainerStyle?: StyleProp; + isSearchScreenFocused?: boolean; }; const transactionItemMobileHeight = 100; @@ -86,7 +87,7 @@ function prepareTransactionsList(item: TransactionListItemType, selectedTransact return {...selectedTransactions, [item.keyForList]: {isSelected: true, canDelete: item.canDelete, canHold: item.canHold, canUnhold: item.canUnhold, action: item.action}}; } -function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchProps) { +function Search({queryJSON, onSearchListScroll, isSearchScreenFocused, contentContainerStyle}: SearchProps) { const {isOffline} = useNetwork(); const {shouldUseNarrowLayout} = useResponsiveLayout(); const styles = useThemeStyles(); @@ -467,6 +468,7 @@ function Search({queryJSON, onSearchListScroll, contentContainerStyle}: SearchPr contentContainerStyle={[contentContainerStyle, styles.pb3]} scrollEventThrottle={1} shouldKeepFocusedItemAtTopOfViewableArea={type === CONST.SEARCH.DATA_TYPES.CHAT} + isScreenFocused={isSearchScreenFocused} /> ); } diff --git a/src/components/SelectionListWithModal/index.tsx b/src/components/SelectionListWithModal/index.tsx index 2ea739f531c82..59e9b268bc525 100644 --- a/src/components/SelectionListWithModal/index.tsx +++ b/src/components/SelectionListWithModal/index.tsx @@ -17,10 +17,11 @@ type SelectionListWithModalProps = BaseSelectionListProp onTurnOnSelectionMode?: (item: TItem | null) => void; shouldAutoTurnOff?: boolean; isSelected?: (item: TItem) => boolean; + isScreenFocused?: boolean; }; function SelectionListWithModal( - {turnOnSelectionModeOnLongPress, onTurnOnSelectionMode, onLongPressRow, sections, shouldAutoTurnOff, isSelected, ...rest}: SelectionListWithModalProps, + {turnOnSelectionModeOnLongPress, onTurnOnSelectionMode, onLongPressRow, isScreenFocused = false, sections, shouldAutoTurnOff, isSelected, ...rest}: SelectionListWithModalProps, ref: ForwardedRef, ) { const [isModalVisible, setIsModalVisible] = useState(false); @@ -79,7 +80,7 @@ function SelectionListWithModal( const handleLongPressRow = (item: TItem) => { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if (!turnOnSelectionModeOnLongPress || !isSmallScreenWidth || item?.isDisabled || item?.isDisabledCheckbox || !isFocused) { + if (!turnOnSelectionModeOnLongPress || !isSmallScreenWidth || item?.isDisabled || item?.isDisabledCheckbox || (!isFocused && !isScreenFocused)) { return; } setLongPressedItem(item); diff --git a/src/pages/Search/SearchPageBottomTab.tsx b/src/pages/Search/SearchPageBottomTab.tsx index 38efb8eb929fa..a91a64d3a8edd 100644 --- a/src/pages/Search/SearchPageBottomTab.tsx +++ b/src/pages/Search/SearchPageBottomTab.tsx @@ -129,6 +129,7 @@ function SearchPageBottomTab() { )} {shouldUseNarrowLayout && (