From a7a7a7a169bf87f63535670ce560cdb3a681e97b Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 30 Apr 2025 14:27:28 +0200 Subject: [PATCH 01/18] getPlatformHeight --- src/components/Search/getPlatformHeight.ts | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/components/Search/getPlatformHeight.ts diff --git a/src/components/Search/getPlatformHeight.ts b/src/components/Search/getPlatformHeight.ts new file mode 100644 index 000000000000..faa0c2bc8381 --- /dev/null +++ b/src/components/Search/getPlatformHeight.ts @@ -0,0 +1,35 @@ +import {Platform} from 'react-native'; +import variables from '@styles/variables'; + +type PlatformHeights = { + [key: string]: number | undefined; +}; + +export const ITEM_HEIGHTS = { + MOBILE: { + TRANSACTION: variables.listItemHeightNormal + variables.optionRowListItemPadding, + WITH_BUTTON: variables.listItemHeightNormal + 12 + variables.optionRowListItemPadding, + STANDARD: variables.listItemHeightNormal + variables.optionRowListItemPadding, + }, + WEB: { + WITH_BUTTON: variables.listItemHeightNormal + 12 + variables.optionRowListItemPadding, + STANDARD: variables.listItemHeightNormal + variables.optionRowListItemPadding, + COMPACT: variables.optionRowHeightCompact + variables.optionRowListItemPadding, + }, + HEADER: variables.optionsListSectionHeaderHeight, +}; + +/** + * Get platform-specific height based on provided heights object. + * + * @param heights - Object containing heights for different platforms (ios, android, web, mobileweb, desktop, default). + * @param fallbackHeight - A default height to return if no matching platform height is found. + * @returns The appropriate height for the current platform. + */ +function getPlatformHeight(heights: PlatformHeights, fallbackHeight: number): number { + const currentPlatform = Platform.OS; + const height = heights[currentPlatform] ?? fallbackHeight; + return Math.max(height, 1); +} + +export default getPlatformHeight; From abb887fe0f347232c81c1c82d8731271eabd67e8 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 30 Apr 2025 14:27:45 +0200 Subject: [PATCH 02/18] fix contentContainerStyle --- src/components/Search/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 2a512b3d9bb4..599883d993fb 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -1,4 +1,5 @@ import {useIsFocused, useNavigation} from '@react-navigation/native'; +import type {ContentStyle} from '@shopify/flash-list'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import type {NativeScrollEvent, NativeSyntheticEvent, StyleProp, ViewStyle, ViewToken} from 'react-native'; import {View} from 'react-native'; @@ -53,7 +54,7 @@ import type {SearchColumnType, SearchQueryJSON, SelectedTransactionInfo, Selecte type SearchProps = { queryJSON: SearchQueryJSON; onSearchListScroll?: (event: NativeSyntheticEvent) => void; - contentContainerStyle?: StyleProp; + contentContainerStyle?: ContentStyle; currentSearchResults?: SearchResults; lastNonEmptySearchResults?: SearchResults; }; @@ -562,7 +563,7 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS /> ) } - contentContainerStyle={[contentContainerStyle, styles.pb3]} + contentContainerStyle={{...contentContainerStyle, ...styles.pb3}} containerStyle={[styles.pv0, type === CONST.SEARCH.DATA_TYPES.CHAT && !isSmallScreenWidth && styles.pt3]} shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()} shouldGroupByReports={shouldGroupByReports} From d7d50567d2d60e6ed7e9a56b24cc6e3fd57e7f12 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 30 Apr 2025 14:39:11 +0200 Subject: [PATCH 03/18] use FlashList and add getItemHeight --- src/components/Search/SearchList.tsx | 102 +++++++++++++++++++++++---- 1 file changed, 87 insertions(+), 15 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 7a6f2d900d46..bf18b0df22b0 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -1,21 +1,22 @@ import {useIsFocused} from '@react-navigation/native'; +import {FlashList} from '@shopify/flash-list'; +import type {FlashListProps, ViewToken} from '@shopify/flash-list'; import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState} from 'react'; import type {ForwardedRef} from 'react'; import {View} from 'react-native'; -import type {FlatList, ListRenderItemInfo, NativeSyntheticEvent, StyleProp, ViewStyle, ViewToken} from 'react-native'; +import type {NativeSyntheticEvent, StyleProp, ViewStyle} from 'react-native'; import {useOnyx} from 'react-native-onyx'; -import Animated from 'react-native-reanimated'; -import type {FlatListPropsWithLayout} from 'react-native-reanimated'; import Checkbox from '@components/Checkbox'; import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; import Modal from '@components/Modal'; import {PressableWithFeedback} from '@components/Pressable'; +import getPlatformHeight, {ITEM_HEIGHTS} from '@components/Search/getPlatformHeight'; import type ChatListItem from '@components/SelectionList/ChatListItem'; import type ReportListItem from '@components/SelectionList/Search/ReportListItem'; import type TaskListItem from '@components/SelectionList/Search/TaskListItem'; import type TransactionListItem from '@components/SelectionList/Search/TransactionListItem'; -import type {ExtendedTargetedEvent, ReportListItemType, SearchListItem} from '@components/SelectionList/types'; +import type {ExtendedTargetedEvent, ReportActionListItemType, ReportListItemType, SearchListItem, TransactionListItemType} from '@components/SelectionList/types'; import Text from '@components/Text'; import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager'; import useKeyboardShortcut from '@hooks/useKeyboardShortcut'; @@ -28,6 +29,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {turnOffMobileSelectionMode, turnOnMobileSelectionMode} from '@libs/actions/MobileSelectionMode'; import {isMobileChrome} from '@libs/Browser'; import {addKeyDownPressListener, removeKeyDownPressListener} from '@libs/KeyboardShortcut/KeyDownPressListener'; +import {isReportActionListItemType, isReportListItemType, isTransactionListItemType} from '@libs/SearchUIUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -39,7 +41,7 @@ type SearchListHandle = { scrollToIndex: (index: number, animated?: boolean) => void; }; -type SearchListProps = Pick, 'onScroll' | 'contentContainerStyle' | 'onEndReached' | 'onEndReachedThreshold' | 'ListFooterComponent'> & { +type SearchListProps = Pick, 'onScroll' | 'contentContainerStyle' | 'onEndReached' | 'onEndReachedThreshold' | 'ListFooterComponent' | 'estimatedItemSize'> & { data: SearchListItem[]; /** Default renderer for every item in the list */ @@ -78,6 +80,8 @@ type SearchListProps = Pick, 'onScroll' onViewableItemsChanged?: (info: {changed: ViewToken[]; viewableItems: ViewToken[]}) => void; }; +const keyExtractor = (item: SearchListItem, index: number) => item.keyForList ?? `${index}`; + function SearchList( { data, @@ -98,6 +102,7 @@ function SearchList( queryJSONHash, shouldGroupByReports, onViewableItemsChanged, + estimatedItemSize = ITEM_HEIGHTS.MOBILE.STANDARD, }: SearchListProps, ref: ForwardedRef, ) { @@ -108,7 +113,7 @@ function SearchList( }, 0); const {translate} = useLocalize(); const isFocused = useIsFocused(); - const listRef = useRef>(null); + const listRef = useRef>(null); const hasKeyBeenPressed = useRef(false); const [itemsToHighlight, setItemsToHighlight] = useState | null>(null); const itemFocusTimeoutRef = useRef(null); @@ -117,7 +122,7 @@ function SearchList( // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout here because there is a race condition that causes shouldUseNarrowLayout to change indefinitely in this component // See https://github.com/Expensify/App/issues/48675 for more details // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth - const {isSmallScreenWidth} = useResponsiveLayout(); + const {isSmallScreenWidth, isLargeScreenWidth} = useResponsiveLayout(); const [isModalVisible, setIsModalVisible] = useState(false); const {selectionMode} = useMobileSelectionMode(); @@ -288,8 +293,74 @@ function SearchList( useImperativeHandle(ref, () => ({scrollAndHighlightItem, scrollToIndex}), [scrollAndHighlightItem, scrollToIndex]); + const getItemHeight = useCallback( + (item: SearchListItem): number => { + try { + const reportListItem = item as ReportListItemType; + const transactionListItem = item as TransactionListItemType; + const reportActionListItem = item as ReportActionListItemType; + + const isTransaction = isTransactionListItemType(transactionListItem); + const isReportAction = isReportActionListItemType(reportActionListItem); + + if (isTransaction || isReportAction) { + const itemAction = transactionListItem?.action; + const isItemActionView = isTransaction && itemAction === CONST.SEARCH.ACTION_TYPES.VIEW; + + const mobileHeight = isItemActionView ? ITEM_HEIGHTS.MOBILE.STANDARD : ITEM_HEIGHTS.MOBILE.WITH_BUTTON; + const webHeight = isItemActionView ? ITEM_HEIGHTS.WEB.STANDARD : ITEM_HEIGHTS.WEB.WITH_BUTTON; + const compactOrWebHeight = isLargeScreenWidth ? ITEM_HEIGHTS.WEB.COMPACT : webHeight; + + const calculatedHeight = getPlatformHeight( + { + // Mobile platforms use mobileHeight + [CONST.PLATFORM.IOS]: mobileHeight, + [CONST.PLATFORM.ANDROID]: mobileHeight, + [CONST.PLATFORM.MOBILEWEB]: mobileHeight, + // Desktop/Web platforms use compact height on large screens, otherwise webHeight + [CONST.PLATFORM.WEB]: compactOrWebHeight, + [CONST.PLATFORM.DESKTOP]: compactOrWebHeight, + }, + ITEM_HEIGHTS.MOBILE.STANDARD, + ); + return calculatedHeight; + } + + if (isReportListItemType(reportListItem)) { + if (!reportListItem.transactions || reportListItem.transactions.length === 0) { + return Math.max(ITEM_HEIGHTS.HEADER, 1); + } + const baseReportItemHeight = isLargeScreenWidth ? variables.optionRowHeight : variables.listItemHeightNormal + 30; + const transactionHeight = isLargeScreenWidth ? variables.optionRowHeightCompact : variables.listItemHeightNormal; + const calculatedHeight = baseReportItemHeight + reportListItem.transactions.length * transactionHeight + variables.optionRowListItemPadding; + return Math.max(calculatedHeight, ITEM_HEIGHTS.HEADER, 1); + } + + console.warn('SearchList: Unhandled item type in getItemHeight, returning estimated size.', item); + return estimatedItemSize; + } catch (error) { + console.error('SearchList: Error calculating item height, returning estimated size.', error, item); + return estimatedItemSize; + } + }, + [isLargeScreenWidth, estimatedItemSize], + ); + + const overrideItemLayout = useCallback( + (layout: {span?: number; size?: number}, item: SearchListItem) => { + const height = getItemHeight(item); + if (layout) { + // Ensure height is a positive number before assigning, fallback to estimatedItemSize if <= 0 + layout.size = height > 0 ? height : estimatedItemSize; + } else { + console.warn('SearchList: Layout object missing in overrideItemLayout for item:', item); + } + }, + [getItemHeight, estimatedItemSize], + ); + const renderItem = useCallback( - ({item, index}: ListRenderItemInfo) => { + ({item, index}: {item: SearchListItem; index: number}) => { const isItemFocused = focusedIndex === index; const isItemHighlighted = !!itemsToHighlight?.has(item.keyForList ?? ''); @@ -352,9 +423,7 @@ function SearchList( accessibilityLabel={translate('workspace.people.selectAll')} isChecked={selectedItemsLength === flattenedTransactions.length} isIndeterminate={selectedItemsLength > 0 && selectedItemsLength !== flattenedTransactions.length} - onPress={() => { - onAllCheckboxPress(); - }} + onPress={onAllCheckboxPress} /> )} @@ -375,18 +444,21 @@ function SearchList( )} - item.keyForList ?? `${index}`} + keyExtractor={keyExtractor} onScroll={onScroll} contentContainerStyle={contentContainerStyle} showsVerticalScrollIndicator={false} - ref={listRef} - extraData={focusedIndex} + estimatedItemSize={estimatedItemSize} + overrideItemLayout={overrideItemLayout} onEndReached={onEndReached} onEndReachedThreshold={onEndReachedThreshold} ListFooterComponent={ListFooterComponent} + drawDistance={1000} + extraData={focusedIndex} removeClippedSubviews onViewableItemsChanged={onViewableItemsChanged} /> From f65d798f95b2bfbc93b07bb1773eec1f9a73cc9a Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 30 Apr 2025 14:48:37 +0200 Subject: [PATCH 04/18] change handleScroll --- src/pages/Search/SearchPageNarrow.tsx | 40 +++++++++++++++------------ 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/pages/Search/SearchPageNarrow.tsx b/src/pages/Search/SearchPageNarrow.tsx index 97e5d1d67d55..560a6a9ad59e 100644 --- a/src/pages/Search/SearchPageNarrow.tsx +++ b/src/pages/Search/SearchPageNarrow.tsx @@ -1,7 +1,7 @@ -import React, {useCallback, useState} from 'react'; -import {View} from 'react-native'; +import React, {useCallback, useRef, useState} from 'react'; +import {NativeScrollEvent, NativeSyntheticEvent, View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; -import Animated, {clamp, runOnJS, useAnimatedScrollHandler, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; +import Animated, {clamp, runOnJS, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -73,31 +73,37 @@ function SearchPageNarrow({queryJSON, policyID, searchName, headerButtonsOptions useHandleBackButton(handleBackButtonPress); - const scrollOffset = useSharedValue(0); + const scrollOffset = useRef(0); const topBarOffset = useSharedValue(StyleUtils.searchHeaderDefaultOffset); const topBarAnimatedStyle = useAnimatedStyle(() => ({ top: topBarOffset.get(), })); - const scrollHandler = useAnimatedScrollHandler({ - onScroll: (event) => { - runOnJS(triggerScrollEvent)(); - const {contentOffset, layoutMeasurement, contentSize} = event; - if (windowHeight > contentSize.height) { + const handleScroll = useCallback( + (event: NativeSyntheticEvent) => { + triggerScrollEvent(); + + const {contentOffset, layoutMeasurement, contentSize} = event.nativeEvent; + const currentOffset = contentOffset.y; + + if (windowHeight >= contentSize.height || currentOffset < 0) { + scrollOffset.current = Math.max(0, currentOffset); return; } - const currentOffset = contentOffset.y; - const isScrollingDown = currentOffset > scrollOffset.get(); - const distanceScrolled = currentOffset - scrollOffset.get(); - if (isScrollingDown && contentOffset.y > TOO_CLOSE_TO_TOP_DISTANCE) { + const previousScrollOffset = scrollOffset.current; + const isScrollingDown = currentOffset > previousScrollOffset; + const distanceScrolled = currentOffset - previousScrollOffset; + + if (isScrollingDown && currentOffset > TOO_CLOSE_TO_TOP_DISTANCE) { topBarOffset.set(clamp(topBarOffset.get() - distanceScrolled, variables.minimalTopBarOffset, StyleUtils.searchHeaderDefaultOffset)); - } else if (!isScrollingDown && distanceScrolled < 0 && contentOffset.y + layoutMeasurement.height < contentSize.height - TOO_CLOSE_TO_BOTTOM_DISTANCE) { + } else if (!isScrollingDown && distanceScrolled < 0 && currentOffset + layoutMeasurement.height < contentSize.height - TOO_CLOSE_TO_BOTTOM_DISTANCE) { topBarOffset.set(withTiming(StyleUtils.searchHeaderDefaultOffset, {duration: ANIMATION_DURATION_IN_MS})); } - scrollOffset.set(currentOffset); + scrollOffset.current = currentOffset; }, - }); + [topBarOffset, triggerScrollEvent, windowHeight], + ); const handleOnBackButtonPress = () => Navigation.goBack(ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery()})); @@ -215,7 +221,7 @@ function SearchPageNarrow({queryJSON, policyID, searchName, headerButtonsOptions lastNonEmptySearchResults={lastNonEmptySearchResults} key={queryJSON.hash} queryJSON={queryJSON} - onSearchListScroll={scrollHandler} + onSearchListScroll={handleScroll} contentContainerStyle={!selectionMode?.isEnabled ? styles.searchListContentContainerStyles : undefined} /> From 70b83908b9d9ca6fc441927a574cac80fd314c6d Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 30 Apr 2025 14:48:56 +0200 Subject: [PATCH 05/18] variables --- src/styles/variables.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/styles/variables.ts b/src/styles/variables.ts index f2f0494763f7..269b8978a507 100644 --- a/src/styles/variables.ts +++ b/src/styles/variables.ts @@ -312,4 +312,13 @@ export default { w96: 96, w184: 184, w191: 191, + + optionRowTransactionItemMobileHeight: 104, + optionRowMobileItemHeightWithButton: 104, + optionRowMobileItemHeight: 92, + optionRowWebItemHeightWithButton: 104, + optionRowWebItemHeight: 96, + optionRowWebItemHeightCompact: 64, + optionRowListItemPadding: 8, + optionRowSearchHeaderHeight: 54, } as const; From 3a4ff6df18d05b27f8692ff073ef188b23e7ecd1 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 30 Apr 2025 15:24:42 +0200 Subject: [PATCH 06/18] lint --- src/components/Search/SearchList.tsx | 8 +++----- src/components/Search/index.tsx | 2 +- src/pages/Search/SearchPageNarrow.tsx | 5 +++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 547411a4bd3b..0a9695327127 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -349,12 +349,10 @@ function SearchList( const overrideItemLayout = useCallback( (layout: {span?: number; size?: number}, item: SearchListItem) => { const height = getItemHeight(item); - if (layout) { - // Ensure height is a positive number before assigning, fallback to estimatedItemSize if <= 0 - layout.size = height > 0 ? height : estimatedItemSize; - } else { - console.warn('SearchList: Layout object missing in overrideItemLayout for item:', item); + if (!layout) { + return; } + layout.size = height > 0 ? height : estimatedItemSize; }, [getItemHeight, estimatedItemSize], ); diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 78b7fcd34d70..dd165a804898 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -1,7 +1,7 @@ import {useIsFocused, useNavigation} from '@react-navigation/native'; import type {ContentStyle} from '@shopify/flash-list'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; -import type {NativeScrollEvent, NativeSyntheticEvent, StyleProp, ViewStyle, ViewToken} from 'react-native'; +import type {NativeScrollEvent, NativeSyntheticEvent, ViewToken} from 'react-native'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import FullPageErrorView from '@components/BlockingViews/FullPageErrorView'; diff --git a/src/pages/Search/SearchPageNarrow.tsx b/src/pages/Search/SearchPageNarrow.tsx index d8a425e6db09..71103679e08c 100644 --- a/src/pages/Search/SearchPageNarrow.tsx +++ b/src/pages/Search/SearchPageNarrow.tsx @@ -1,7 +1,8 @@ import React, {useCallback, useRef, useState} from 'react'; -import {NativeScrollEvent, NativeSyntheticEvent, View} from 'react-native'; +import type {NativeScrollEvent, NativeSyntheticEvent} from 'react-native'; +import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; -import Animated, {clamp, runOnJS, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; +import Animated, {clamp, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; From 10c0a43e6b87c183151bd379be14e96703f7c9fe Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Thu, 8 May 2025 11:51:25 +0200 Subject: [PATCH 07/18] getPlatform --- src/components/Search/getPlatformHeight.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/Search/getPlatformHeight.ts b/src/components/Search/getPlatformHeight.ts index faa0c2bc8381..90dbab9308d9 100644 --- a/src/components/Search/getPlatformHeight.ts +++ b/src/components/Search/getPlatformHeight.ts @@ -1,4 +1,5 @@ import {Platform} from 'react-native'; +import getPlatform from '@libs/getPlatform'; import variables from '@styles/variables'; type PlatformHeights = { @@ -27,7 +28,7 @@ export const ITEM_HEIGHTS = { * @returns The appropriate height for the current platform. */ function getPlatformHeight(heights: PlatformHeights, fallbackHeight: number): number { - const currentPlatform = Platform.OS; + const currentPlatform = getPlatform(); const height = heights[currentPlatform] ?? fallbackHeight; return Math.max(height, 1); } From 481ec6a20a14692f8b5cc83c2daa468af944377d Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Thu, 8 May 2025 12:20:31 +0200 Subject: [PATCH 08/18] animated header fix --- src/components/Search/SearchList.tsx | 4 ++- src/pages/Search/SearchPageNarrow.tsx | 39 +++++++++++---------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 0a9695327127..9402270d6870 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -6,6 +6,7 @@ import type {ForwardedRef} from 'react'; import {View} from 'react-native'; import type {NativeSyntheticEvent, StyleProp, ViewStyle} from 'react-native'; import {useOnyx} from 'react-native-onyx'; +import Animated from 'react-native-reanimated'; import Checkbox from '@components/Checkbox'; import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; @@ -81,6 +82,7 @@ type SearchListProps = Pick, 'onScroll' | 'conten }; const keyExtractor = (item: SearchListItem, index: number) => item.keyForList ?? `${index}`; +const AnimatedFlashList = Animated.createAnimatedComponent>(FlashList); function SearchList( { @@ -435,7 +437,7 @@ function SearchList( )} )} - (StyleUtils.searchHeaderDefaultOffset); const topBarAnimatedStyle = useAnimatedStyle(() => ({ top: topBarOffset.get(), })); - const handleScroll = useCallback( - (event: NativeSyntheticEvent) => { - triggerScrollEvent(); - - const {contentOffset, layoutMeasurement, contentSize} = event.nativeEvent; - const currentOffset = contentOffset.y; - - if (windowHeight >= contentSize.height || currentOffset < 0) { - scrollOffset.current = Math.max(0, currentOffset); + const scrollHandler = useAnimatedScrollHandler({ + onScroll: (event) => { + runOnJS(triggerScrollEvent)(); + const {contentOffset, layoutMeasurement, contentSize} = event; + if (windowHeight > contentSize.height) { return; } + const currentOffset = contentOffset.y; + const isScrollingDown = currentOffset > scrollOffset.get(); + const distanceScrolled = currentOffset - scrollOffset.get(); - const previousScrollOffset = scrollOffset.current; - const isScrollingDown = currentOffset > previousScrollOffset; - const distanceScrolled = currentOffset - previousScrollOffset; - - if (isScrollingDown && currentOffset > TOO_CLOSE_TO_TOP_DISTANCE) { + if (isScrollingDown && contentOffset.y > TOO_CLOSE_TO_TOP_DISTANCE) { topBarOffset.set(clamp(topBarOffset.get() - distanceScrolled, variables.minimalTopBarOffset, StyleUtils.searchHeaderDefaultOffset)); - } else if (!isScrollingDown && distanceScrolled < 0 && currentOffset + layoutMeasurement.height < contentSize.height - TOO_CLOSE_TO_BOTTOM_DISTANCE) { + } else if (!isScrollingDown && distanceScrolled < 0 && contentOffset.y + layoutMeasurement.height < contentSize.height - TOO_CLOSE_TO_BOTTOM_DISTANCE) { topBarOffset.set(withTiming(StyleUtils.searchHeaderDefaultOffset, {duration: ANIMATION_DURATION_IN_MS})); } - scrollOffset.current = currentOffset; + scrollOffset.set(currentOffset); }, - [topBarOffset, triggerScrollEvent, windowHeight], - ); + }); const handleOnBackButtonPress = () => Navigation.goBack(ROUTES.SEARCH_ROOT.getRoute({query: buildCannedSearchQuery()})); @@ -222,7 +215,7 @@ function SearchPageNarrow({queryJSON, policyID, searchName, headerButtonsOptions lastNonEmptySearchResults={lastNonEmptySearchResults} key={queryJSON.hash} queryJSON={queryJSON} - onSearchListScroll={handleScroll} + onSearchListScroll={scrollHandler} contentContainerStyle={!selectionMode?.isEnabled ? styles.searchListContentContainerStyles : undefined} /> From c622ffe5210d8d07f7cb0665968fe52501e6b464 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Tue, 13 May 2025 12:17:54 +0200 Subject: [PATCH 09/18] chore: fix lint issues due to new ESLint rules --- src/components/Search/SearchList.tsx | 3 +-- src/components/Search/getPlatformHeight.ts | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 306a66bd97b6..148b7098775a 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -343,7 +343,6 @@ function SearchList( return Math.max(calculatedHeight, ITEM_HEIGHTS.HEADER, 1); } - console.warn('SearchList: Unhandled item type in getItemHeight, returning estimated size.', item); return estimatedItemSize; } catch (error) { console.error('SearchList: Error calculating item height, returning estimated size.', error, item); @@ -359,6 +358,7 @@ function SearchList( if (!layout) { return; } + // eslint-disable-next-line no-param-reassign layout.size = height > 0 ? height : estimatedItemSize; }, [getItemHeight, estimatedItemSize], @@ -468,7 +468,6 @@ function SearchList( removeClippedSubviews onViewableItemsChanged={onViewableItemsChanged} onLayout={onLayout} - /> ; -export const ITEM_HEIGHTS = { +const ITEM_HEIGHTS = { MOBILE: { TRANSACTION: variables.listItemHeightNormal + variables.optionRowListItemPadding, WITH_BUTTON: variables.listItemHeightNormal + 12 + variables.optionRowListItemPadding, @@ -34,3 +32,4 @@ function getPlatformHeight(heights: PlatformHeights, fallbackHeight: number): nu } export default getPlatformHeight; +export {ITEM_HEIGHTS}; From 084e165dba7639ff4405588d24d33179e4ef1425 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Tue, 13 May 2025 12:30:37 +0200 Subject: [PATCH 10/18] chore: fix lint issues due to new ESLint rules --- src/components/Search/SearchList.tsx | 1 + src/components/Search/getPlatformHeight.ts | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 148b7098775a..6bd8b59ed00f 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -364,6 +364,7 @@ function SearchList( [getItemHeight, estimatedItemSize], ); + // eslint-disable-next-line react/no-unused-prop-types const renderItem = useCallback( ({item, index}: {item: SearchListItem; index: number}) => { const isItemFocused = focusedIndex === index; diff --git a/src/components/Search/getPlatformHeight.ts b/src/components/Search/getPlatformHeight.ts index 54db24d906ef..d23b62367f75 100644 --- a/src/components/Search/getPlatformHeight.ts +++ b/src/components/Search/getPlatformHeight.ts @@ -1,4 +1,3 @@ -import {Platform} from 'react-native'; import getPlatform from '@libs/getPlatform'; import variables from '@styles/variables'; From 2b2132d2705aef5ac58b573f5653f36d68463cec Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Tue, 13 May 2025 12:42:28 +0200 Subject: [PATCH 11/18] clean --- src/components/Search/SearchList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 6bd8b59ed00f..426dfc823529 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -12,7 +12,7 @@ import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; import Modal from '@components/Modal'; import {PressableWithFeedback} from '@components/Pressable'; -import getPlatformHeight, {ITEM_HEIGHTS} from '@components/Search/getPlatformHeight'; +import getPlatformHeight, {ITEM_HEIGHTS} from './getPlatformHeight'; import type ChatListItem from '@components/SelectionList/ChatListItem'; import type ReportListItem from '@components/SelectionList/Search/ReportListItem'; import type TaskListItem from '@components/SelectionList/Search/TaskListItem'; @@ -364,8 +364,8 @@ function SearchList( [getItemHeight, estimatedItemSize], ); - // eslint-disable-next-line react/no-unused-prop-types const renderItem = useCallback( + // eslint-disable-next-line react/no-unused-prop-types ({item, index}: {item: SearchListItem; index: number}) => { const isItemFocused = focusedIndex === index; const isItemHighlighted = !!itemsToHighlight?.has(item.keyForList ?? ''); From e22fc29d195657c92aa13e6eaa96a2b04bb3e86f Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Tue, 13 May 2025 13:06:08 +0200 Subject: [PATCH 12/18] prettier --- src/components/Search/SearchList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 426dfc823529..bbd9dc0385fa 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -12,7 +12,6 @@ import * as Expensicons from '@components/Icon/Expensicons'; import MenuItem from '@components/MenuItem'; import Modal from '@components/Modal'; import {PressableWithFeedback} from '@components/Pressable'; -import getPlatformHeight, {ITEM_HEIGHTS} from './getPlatformHeight'; import type ChatListItem from '@components/SelectionList/ChatListItem'; import type ReportListItem from '@components/SelectionList/Search/ReportListItem'; import type TaskListItem from '@components/SelectionList/Search/TaskListItem'; @@ -34,6 +33,7 @@ import {isReportActionListItemType, isReportListItemType, isTransactionListItemT import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import getPlatformHeight, {ITEM_HEIGHTS} from './getPlatformHeight'; type SearchListItem = TransactionListItemType | ReportListItemType | ReportActionListItemType | TaskListItemType; type SearchListItemComponentType = typeof TransactionListItem | typeof ChatListItem | typeof ReportListItem | typeof TaskListItem; From 960f88c5796e2b896877f74b862d4b5251c03bb1 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 14 May 2025 12:08:53 +0200 Subject: [PATCH 13/18] fix initial render height --- src/components/Search/SearchList.tsx | 41 +++++++++++----------- src/components/Search/getPlatformHeight.ts | 34 ------------------ src/components/Search/itemHeights.ts | 24 +++++++++++++ src/styles/variables.ts | 18 ++++++---- 4 files changed, 56 insertions(+), 61 deletions(-) delete mode 100644 src/components/Search/getPlatformHeight.ts create mode 100644 src/components/Search/itemHeights.ts diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index bbd9dc0385fa..d9be30899714 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -33,7 +33,7 @@ import {isReportActionListItemType, isReportListItemType, isTransactionListItemT import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import getPlatformHeight, {ITEM_HEIGHTS} from './getPlatformHeight'; +import {ITEM_HEIGHTS} from './itemHeights'; type SearchListItem = TransactionListItemType | ReportListItemType | ReportActionListItemType | TaskListItemType; type SearchListItemComponentType = typeof TransactionListItem | typeof ChatListItem | typeof ReportListItem | typeof TaskListItem; @@ -108,7 +108,7 @@ function SearchList( queryJSONHash, shouldGroupByReports, onViewableItemsChanged, - estimatedItemSize = ITEM_HEIGHTS.MOBILE.STANDARD, + estimatedItemSize = ITEM_HEIGHTS.NARROW_WITHOUT_DRAWER.STANDARD, onLayout, }: SearchListProps, ref: ForwardedRef, @@ -129,7 +129,7 @@ function SearchList( // We need to use isSmallScreenWidth instead of shouldUseNarrowLayout here because there is a race condition that causes shouldUseNarrowLayout to change indefinitely in this component // See https://github.com/Expensify/App/issues/48675 for more details // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth - const {isSmallScreenWidth, isLargeScreenWidth} = useResponsiveLayout(); + const {isSmallScreenWidth, isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); const [isModalVisible, setIsModalVisible] = useState(false); const {selectionMode} = useMobileSelectionMode(); @@ -312,25 +312,24 @@ function SearchList( if (isTransaction || isReportAction) { const itemAction = transactionListItem?.action; + // VIEW is the only action type that should be compact const isItemActionView = isTransaction && itemAction === CONST.SEARCH.ACTION_TYPES.VIEW; - const mobileHeight = isItemActionView ? ITEM_HEIGHTS.MOBILE.STANDARD : ITEM_HEIGHTS.MOBILE.WITH_BUTTON; - const webHeight = isItemActionView ? ITEM_HEIGHTS.WEB.STANDARD : ITEM_HEIGHTS.WEB.WITH_BUTTON; - const compactOrWebHeight = isLargeScreenWidth ? ITEM_HEIGHTS.WEB.COMPACT : webHeight; - - const calculatedHeight = getPlatformHeight( - { - // Mobile platforms use mobileHeight - [CONST.PLATFORM.IOS]: mobileHeight, - [CONST.PLATFORM.ANDROID]: mobileHeight, - [CONST.PLATFORM.MOBILEWEB]: mobileHeight, - // Desktop/Web platforms use compact height on large screens, otherwise webHeight - [CONST.PLATFORM.WEB]: compactOrWebHeight, - [CONST.PLATFORM.DESKTOP]: compactOrWebHeight, - }, - ITEM_HEIGHTS.MOBILE.STANDARD, - ); - return calculatedHeight; + // Determine which layout to use based on screen size and drawer state + let heightConstants; + + if (shouldUseNarrowLayout) { + // For narrow screens without drawer (mobile or collapsed desktop) + heightConstants = isItemActionView ? ITEM_HEIGHTS.NARROW_WITHOUT_DRAWER.STANDARD : ITEM_HEIGHTS.NARROW_WITHOUT_DRAWER.WITH_BUTTON; + } else if (!isLargeScreenWidth) { + // For narrow screens with drawer + heightConstants = isItemActionView ? ITEM_HEIGHTS.NARROW_WITH_DRAWER.STANDARD : ITEM_HEIGHTS.NARROW_WITH_DRAWER.WITH_BUTTON; + } else { + // For wide screens (desktop) + heightConstants = ITEM_HEIGHTS.WIDE.STANDARD; + } + + return heightConstants; } if (isReportListItemType(reportListItem)) { @@ -349,7 +348,7 @@ function SearchList( return estimatedItemSize; } }, - [isLargeScreenWidth, estimatedItemSize], + [isLargeScreenWidth, estimatedItemSize, shouldUseNarrowLayout], ); const overrideItemLayout = useCallback( diff --git a/src/components/Search/getPlatformHeight.ts b/src/components/Search/getPlatformHeight.ts deleted file mode 100644 index d23b62367f75..000000000000 --- a/src/components/Search/getPlatformHeight.ts +++ /dev/null @@ -1,34 +0,0 @@ -import getPlatform from '@libs/getPlatform'; -import variables from '@styles/variables'; - -type PlatformHeights = Record; - -const ITEM_HEIGHTS = { - MOBILE: { - TRANSACTION: variables.listItemHeightNormal + variables.optionRowListItemPadding, - WITH_BUTTON: variables.listItemHeightNormal + 12 + variables.optionRowListItemPadding, - STANDARD: variables.listItemHeightNormal + variables.optionRowListItemPadding, - }, - WEB: { - WITH_BUTTON: variables.listItemHeightNormal + 12 + variables.optionRowListItemPadding, - STANDARD: variables.listItemHeightNormal + variables.optionRowListItemPadding, - COMPACT: variables.optionRowHeightCompact + variables.optionRowListItemPadding, - }, - HEADER: variables.optionsListSectionHeaderHeight, -}; - -/** - * Get platform-specific height based on provided heights object. - * - * @param heights - Object containing heights for different platforms (ios, android, web, mobileweb, desktop, default). - * @param fallbackHeight - A default height to return if no matching platform height is found. - * @returns The appropriate height for the current platform. - */ -function getPlatformHeight(heights: PlatformHeights, fallbackHeight: number): number { - const currentPlatform = getPlatform(); - const height = heights[currentPlatform] ?? fallbackHeight; - return Math.max(height, 1); -} - -export default getPlatformHeight; -export {ITEM_HEIGHTS}; diff --git a/src/components/Search/itemHeights.ts b/src/components/Search/itemHeights.ts new file mode 100644 index 000000000000..b7d540c46cda --- /dev/null +++ b/src/components/Search/itemHeights.ts @@ -0,0 +1,24 @@ +import variables from '@styles/variables'; + +const ITEM_HEIGHTS = { + // Constants for wide screen layout + WIDE: { + STANDARD: variables.optionRowWideItemHeight + variables.optionRowListItemPadding, + }, + + // Constants for narrow screen with drawer + NARROW_WITH_DRAWER: { + STANDARD: variables.optionRowNarrowWithDrawerItemHeight + variables.optionRowListItemPadding, + WITH_BUTTON: variables.optionRowNarrowWithDrawerItemHeightWithButton + variables.optionRowListItemPadding, + }, + + // Constants for narrow screen without drawer (mobile-like) + NARROW_WITHOUT_DRAWER: { + STANDARD: variables.optionRowNarrowWithoutDrawerItemHeight + variables.optionRowListItemPadding, + WITH_BUTTON: variables.optionRowNarrowWithoutDrawerItemHeightWithButton + variables.optionRowListItemPadding, + }, + + HEADER: variables.optionRowSearchHeaderHeight, +} as const; + +export default ITEM_HEIGHTS; diff --git a/src/styles/variables.ts b/src/styles/variables.ts index 31ebf101284d..dcc5bf862fd1 100644 --- a/src/styles/variables.ts +++ b/src/styles/variables.ts @@ -318,12 +318,18 @@ export default { w184: 184, w191: 191, - optionRowTransactionItemMobileHeight: 104, - optionRowMobileItemHeightWithButton: 104, - optionRowMobileItemHeight: 92, - optionRowWebItemHeightWithButton: 104, - optionRowWebItemHeight: 96, - optionRowWebItemHeightCompact: 64, + // Transaction item row heights based on layout types + // Wide screen (desktop) layout + optionRowWideItemHeight: 64, + + // Narrow screen with drawer layout + optionRowNarrowWithDrawerItemHeight: 96, + optionRowNarrowWithDrawerItemHeightWithButton: 104, + + // Narrow screen without drawer (mobile-like) layout + optionRowNarrowWithoutDrawerItemHeight: 92, + optionRowNarrowWithoutDrawerItemHeightWithButton: 104, + optionRowListItemPadding: 8, optionRowSearchHeaderHeight: 54, } as const; From 8ab6f8355019096d8e7231d64ccc2efe45d35d02 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 14 May 2025 12:18:51 +0200 Subject: [PATCH 14/18] lint --- src/components/Search/SearchList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index d9be30899714..c0d18406d9cd 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -33,7 +33,7 @@ import {isReportActionListItemType, isReportListItemType, isTransactionListItemT import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import {ITEM_HEIGHTS} from './itemHeights'; +import ITEM_HEIGHTS from './itemHeights'; type SearchListItem = TransactionListItemType | ReportListItemType | ReportActionListItemType | TaskListItemType; type SearchListItemComponentType = typeof TransactionListItem | typeof ChatListItem | typeof ReportListItem | typeof TaskListItem; From 4a1ee27bcffb342a4a05806b4e81b0fae0ad75d1 Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 21 May 2025 15:15:02 +0200 Subject: [PATCH 15/18] change margin for skeleton --- src/components/Skeletons/SearchStatusSkeleton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Skeletons/SearchStatusSkeleton.tsx b/src/components/Skeletons/SearchStatusSkeleton.tsx index bf897233c584..e6e4267bbb9e 100644 --- a/src/components/Skeletons/SearchStatusSkeleton.tsx +++ b/src/components/Skeletons/SearchStatusSkeleton.tsx @@ -14,7 +14,7 @@ function SearchStatusSkeleton({shouldAnimate = true}: SearchStatusSkeletonProps) const styles = useThemeStyles(); return ( - + Date: Wed, 21 May 2025 17:08:58 +0200 Subject: [PATCH 16/18] do size calculation --- src/components/Search/SearchList.tsx | 19 ++++++++++++++----- src/components/Search/index.tsx | 1 + src/styles/variables.ts | 11 +++++++++++ src/types/onyx/SearchResults.ts | 3 +++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index c0d18406d9cd..7a82d8741b69 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -75,6 +75,9 @@ type SearchListProps = Pick, 'onScroll' | 'conten /** The hash of the queryJSON */ queryJSONHash: number; + /** The type of the queryJSON */ + queryJSONHType: string; + /** Whether to group the list by reports */ shouldGroupByReports?: boolean; @@ -110,6 +113,7 @@ function SearchList( onViewableItemsChanged, estimatedItemSize = ITEM_HEIGHTS.NARROW_WITHOUT_DRAWER.STANDARD, onLayout, + queryJSONHType, }: SearchListProps, ref: ForwardedRef, ) { @@ -311,6 +315,9 @@ function SearchList( const isReportAction = isReportActionListItemType(reportActionListItem); if (isTransaction || isReportAction) { + if (queryJSONHType === CONST.SEARCH.DATA_TYPES.CHAT) { + return reportListItem?.childReportID ? variables.searchListItemHeightChat : variables.searchListItemHeightChatCompact; + } const itemAction = transactionListItem?.action; // VIEW is the only action type that should be compact const isItemActionView = isTransaction && itemAction === CONST.SEARCH.ACTION_TYPES.VIEW; @@ -331,18 +338,20 @@ function SearchList( return heightConstants; } - if (isReportListItemType(reportListItem)) { if (!reportListItem.transactions || reportListItem.transactions.length === 0) { return Math.max(ITEM_HEIGHTS.HEADER, 1); } - const baseReportItemHeight = isLargeScreenWidth ? variables.optionRowHeight : variables.listItemHeightNormal + 30; - const transactionHeight = isLargeScreenWidth ? variables.optionRowHeightCompact : variables.listItemHeightNormal; - const calculatedHeight = baseReportItemHeight + reportListItem.transactions.length * transactionHeight + variables.optionRowListItemPadding; + const baseReportItemHeight = isLargeScreenWidth + ? variables.searchOptionRowMargin + variables.searchOptionRowBaseHeight + variables.searchOptionRowLargeFooterHeight + : variables.searchOptionRowMargin + variables.searchOptionRowBaseHeight + variables.searchOptionRowSmallFooterHeight; + const transactionHeight = variables.searchOptionRowTransactionHeight; + const calculatedHeight = + baseReportItemHeight + reportListItem.transactions.length * transactionHeight + variables.optionRowListItemPadding + variables.searchOptionRowMargin; return Math.max(calculatedHeight, ITEM_HEIGHTS.HEADER, 1); } - return estimatedItemSize; + return isLargeScreenWidth ? variables.searchListItemHeightLargeScreen : variables.searchListItemHeightSmallScreen; } catch (error) { console.error('SearchList: Error calculating item height, returning estimated size.', error, item); return estimatedItemSize; diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 7a8dc5079281..948f52ad54b7 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -581,6 +581,7 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS ) : undefined } queryJSONHash={hash} + queryJSONHType={type} onViewableItemsChanged={onViewableItemsChanged} onLayout={() => handleSelectionListScroll(sortedSelectedData, searchListRef.current)} /> diff --git a/src/styles/variables.ts b/src/styles/variables.ts index c61017027c03..bb6fe9fecc90 100644 --- a/src/styles/variables.ts +++ b/src/styles/variables.ts @@ -333,4 +333,15 @@ export default { optionRowListItemPadding: 8, optionRowSearchHeaderHeight: 54, + + // SearchList item heights + searchListItemHeightLargeScreen: 72, + searchListItemHeightSmallScreen: 96, + searchListItemHeightChat: 351, + searchListItemHeightChatCompact: 105, + searchOptionRowTransactionHeight: 52, + searchOptionRowBaseHeight: 52, + searchOptionRowSmallFooterHeight: 28, + searchOptionRowLargeFooterHeight: 17, + searchOptionRowMargin: 6, } as const; diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts index e9d4ff5d6432..2610f7191b0a 100644 --- a/src/types/onyx/SearchResults.ts +++ b/src/types/onyx/SearchResults.ts @@ -179,6 +179,9 @@ type SearchReport = { /** The policy name to use for an archived report */ oldPolicyName?: string; + + /** The ID of the chat report associated with this report item, if any */ + childReportID?: string; }; /** Model of report action search result */ From 2f03c88339bd4c6bb6e338d960d9ce1506052fdb Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Wed, 21 May 2025 17:19:43 +0200 Subject: [PATCH 17/18] lint --- src/components/Search/SearchList.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 7a82d8741b69..09f68b5e9a6b 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -357,7 +357,7 @@ function SearchList( return estimatedItemSize; } }, - [isLargeScreenWidth, estimatedItemSize, shouldUseNarrowLayout], + [isLargeScreenWidth, estimatedItemSize, shouldUseNarrowLayout, queryJSONHType], ); const overrideItemLayout = useCallback( From d9a23af5e0001db9199ade6b6e2c6b91b51ecfcc Mon Sep 17 00:00:00 2001 From: Taras Perun Date: Thu, 22 May 2025 11:53:24 +0200 Subject: [PATCH 18/18] typo queryJSONType --- src/components/Search/SearchList.tsx | 8 ++++---- src/components/Search/index.tsx | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Search/SearchList.tsx b/src/components/Search/SearchList.tsx index 09f68b5e9a6b..528a3ae1fa6b 100644 --- a/src/components/Search/SearchList.tsx +++ b/src/components/Search/SearchList.tsx @@ -76,7 +76,7 @@ type SearchListProps = Pick, 'onScroll' | 'conten queryJSONHash: number; /** The type of the queryJSON */ - queryJSONHType: string; + queryJSONType: string; /** Whether to group the list by reports */ shouldGroupByReports?: boolean; @@ -113,7 +113,7 @@ function SearchList( onViewableItemsChanged, estimatedItemSize = ITEM_HEIGHTS.NARROW_WITHOUT_DRAWER.STANDARD, onLayout, - queryJSONHType, + queryJSONType, }: SearchListProps, ref: ForwardedRef, ) { @@ -315,7 +315,7 @@ function SearchList( const isReportAction = isReportActionListItemType(reportActionListItem); if (isTransaction || isReportAction) { - if (queryJSONHType === CONST.SEARCH.DATA_TYPES.CHAT) { + if (queryJSONType === CONST.SEARCH.DATA_TYPES.CHAT) { return reportListItem?.childReportID ? variables.searchListItemHeightChat : variables.searchListItemHeightChatCompact; } const itemAction = transactionListItem?.action; @@ -357,7 +357,7 @@ function SearchList( return estimatedItemSize; } }, - [isLargeScreenWidth, estimatedItemSize, shouldUseNarrowLayout, queryJSONHType], + [isLargeScreenWidth, estimatedItemSize, shouldUseNarrowLayout, queryJSONType], ); const overrideItemLayout = useCallback( diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 948f52ad54b7..5c1efab9c134 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -581,7 +581,7 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS ) : undefined } queryJSONHash={hash} - queryJSONHType={type} + queryJSONType={type} onViewableItemsChanged={onViewableItemsChanged} onLayout={() => handleSelectionListScroll(sortedSelectedData, searchListRef.current)} />