Skip to content

Commit

Permalink
Merge pull request #52278 from FitseTLT/fix-search-page-long-press-re…
Browse files Browse the repository at this point in the history
…gression

Fix long press search page regression

(cherry picked from commit faec954)

(CP triggered by Julesssss)
  • Loading branch information
carlosmiceli authored and OSBotify committed Nov 11, 2024
1 parent 3ea0c33 commit bee3b5a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SearchProps = {
queryJSON: SearchQueryJSON;
onSearchListScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
contentContainerStyle?: StyleProp<ViewStyle>;
isSearchScreenFocused?: boolean;
};

const transactionItemMobileHeight = 100;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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}
/>
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/SelectionListWithModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ type SelectionListWithModalProps<TItem extends ListItem> = BaseSelectionListProp
onTurnOnSelectionMode?: (item: TItem | null) => void;
shouldAutoTurnOff?: boolean;
isSelected?: (item: TItem) => boolean;
isScreenFocused?: boolean;
};

function SelectionListWithModal<TItem extends ListItem>(
{turnOnSelectionModeOnLongPress, onTurnOnSelectionMode, onLongPressRow, sections, shouldAutoTurnOff, isSelected, ...rest}: SelectionListWithModalProps<TItem>,
{turnOnSelectionModeOnLongPress, onTurnOnSelectionMode, onLongPressRow, isScreenFocused = false, sections, shouldAutoTurnOff, isSelected, ...rest}: SelectionListWithModalProps<TItem>,
ref: ForwardedRef<SelectionListHandle>,
) {
const [isModalVisible, setIsModalVisible] = useState(false);
Expand Down Expand Up @@ -79,7 +80,7 @@ function SelectionListWithModal<TItem extends ListItem>(

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);
Expand Down
1 change: 1 addition & 0 deletions src/pages/Search/SearchPageBottomTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function SearchPageBottomTab() {
)}
{shouldUseNarrowLayout && (
<Search
isSearchScreenFocused={isActiveCentralPaneRoute}
queryJSON={queryJSON}
onSearchListScroll={scrollHandler}
contentContainerStyle={!selectionMode?.isEnabled ? [styles.searchListContentContainerStyles] : undefined}
Expand Down

0 comments on commit bee3b5a

Please sign in to comment.