Repository navigation
fix: Recently added section shows false empty state on Home #98969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mountiny
merged 17 commits into
Expensify:main
from
callstack-internal:fix/recently-added-false-empty-state
Aug 24, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
07b6339
fix: remembered snapshot and skeleton state for Home Recently added s…
BartekObudzinski 25a38dd
Merge remote-tracking branch 'upstream/main' into fix/recently-added-…
BartekObudzinski e1641a9
fix: correct inaccurate comment about SearchUIUtils bundle cost
BartekObudzinski b840ad1
fix: satisfy spellcheck and drop unused type export
BartekObudzinski 9b91f4a
fix: keep Search snapshot results when a request fails
BartekObudzinski 3975881
fix: drop unused import and type assertion flagged by eslint
BartekObudzinski bbc7ee3
fix: retry a failed Search on reconnect, drop the row cap and the dea…
BartekObudzinski 1302cfd
Merge remote-tracking branch 'upstream/main' into fix/recently-added-…
BartekObudzinski 8f6c3e8
fix: drop isOffline from Search call sites added upstream
BartekObudzinski 421d397
Merge remote-tracking branch 'upstream/main' into fix/recently-added-…
BartekObudzinski 932e469
fix: measure the skeleton without padding and drop stale isOffline deps
BartekObudzinski ce7f027
docs: trim comments down to the non-obvious reasons
BartekObudzinski 1af2d1e
fix: match the skeleton block to the real row height and separators
BartekObudzinski cef3290
Merge remote-tracking branch 'upstream/main' into fix/recently-added-…
BartekObudzinski e47dbbb
fix: keep the empty state spacing as it is on staging
BartekObudzinski fb47ae9
fix: add JSDoc to shouldShowSkeleton, replace em dash in comment
BartekObudzinski 0aa931b
fix: add blank lines before inline comments per review suggestions
BartekObudzinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
src/pages/home/RecentlyAddedSection/RecentlyAddedPlaceholder.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import SkeletonRect from '@components/SkeletonRect'; | ||
| import ItemListSkeletonView from '@components/Skeletons/ItemListSkeletonView'; | ||
|
|
||
| import useContainerWidth from '@hooks/useContainerWidth'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
|
||
| import variables from '@styles/variables'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
|
|
||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
|
|
||
| import EmptyState from './EmptyState'; | ||
|
|
||
| type RecentlyAddedPlaceholderProps = { | ||
| /** When true, renders the shimmer skeleton; when false, renders the empty state. */ | ||
| shouldShowSkeleton: boolean; | ||
| }; | ||
|
mountiny marked this conversation as resolved.
Resolved
|
||
|
|
||
| // Derived from the tokens RecentlyAddedRow uses rather than copied as literals, so the block keeps matching the rows | ||
| // when a token changes. A row is `pv3` around a receipt (pinned to its narrow size on both layouts) beside a merchant | ||
| // line and a muted label line separated by `gap1`, and every row but the last adds a 1px `borderBottom`. | ||
| // `pv3` on the row, top and bottom. | ||
| const ROW_VERTICAL_PADDING = 12 * 2; | ||
| const RECEIPT_WIDTH = variables.h36; | ||
| const RECEIPT_HEIGHT = variables.w40; | ||
| const MERCHANT_LINE_HEIGHT = variables.fontSizeNormalHeight; | ||
| const LABEL_LINE_HEIGHT = variables.lineHeightNormal; | ||
| const TEXT_LINE_GAP = 4; | ||
|
|
||
| // Every row but the last carries a 1px `borderBottom`, which the uniform loader height cannot express. | ||
|
mountiny marked this conversation as resolved.
Resolved
|
||
| const SEPARATORS_HEIGHT = CONST.HOME.SECTION_VISIBLE_LIMIT - 1; | ||
| const ITEM_HEIGHT = ROW_VERTICAL_PADDING + Math.max(RECEIPT_HEIGHT, MERCHANT_LINE_HEIGHT + TEXT_LINE_GAP + LABEL_LINE_HEIGHT); | ||
| const COLUMN_GAP = 12; | ||
| const BAR_HEIGHT = 12; | ||
| const AMOUNT_WIDTH = 56; | ||
| const TYPE_WIDTH = 40; | ||
| const DATE_WIDTH = 64; | ||
| const separatorsSpacerStyle = {height: SEPARATORS_HEIGHT}; | ||
|
|
||
| // ItemListSkeletonView adds `mr5` to every row, so without this offset the right-aligned bars land past the svg and clip. | ||
|
mountiny marked this conversation as resolved.
Resolved
|
||
| const ROW_RIGHT_MARGIN = 20; | ||
|
|
||
| /** Varying the merchant width per row keeps the shimmer from reading as a rigid block. */ | ||
| function getMerchantSkeletonWidth(itemIndex: number) { | ||
| switch (itemIndex % 3) { | ||
| case 0: | ||
| return 120; | ||
| case 1: | ||
| return 96; | ||
| default: | ||
| return 140; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Shimmer while a search may still land, empty state once the answer is settled. Measures its own container rather than | ||
| * the window, because it sits in a Home widget and not in the full-width Search pane. | ||
| */ | ||
| function RecentlyAddedPlaceholder({shouldShowSkeleton}: RecentlyAddedPlaceholderProps) { | ||
| const {onLayout, containerWidth} = useContainerWidth(ROW_RIGHT_MARGIN); | ||
| const styles = useThemeStyles(); | ||
| const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
|
|
||
| const renderSkeletonItem = (args: {itemIndex: number}) => { | ||
| const textX = RECEIPT_WIDTH + COLUMN_GAP; | ||
| const merchantWidth = getMerchantSkeletonWidth(args.itemIndex); | ||
|
|
||
| // Centred as a block against the taller receipt, as the row's flex column is. | ||
|
mountiny marked this conversation as resolved.
Resolved
|
||
| const textBlockHeight = MERCHANT_LINE_HEIGHT + TEXT_LINE_GAP + LABEL_LINE_HEIGHT; | ||
| const blockTop = (ITEM_HEIGHT - textBlockHeight) / 2; | ||
| const firstLineY = blockTop + (MERCHANT_LINE_HEIGHT - BAR_HEIGHT) / 2; | ||
| const secondLineY = blockTop + MERCHANT_LINE_HEIGHT + TEXT_LINE_GAP + (LABEL_LINE_HEIGHT - BAR_HEIGHT) / 2; | ||
|
|
||
| return ( | ||
| <> | ||
| <SkeletonRect | ||
| transform={[{translateX: 0}, {translateY: (ITEM_HEIGHT - RECEIPT_HEIGHT) / 2}]} | ||
| width={RECEIPT_WIDTH} | ||
| height={RECEIPT_HEIGHT} | ||
| borderRadius={4} | ||
| /> | ||
| <SkeletonRect | ||
| transform={[{translateX: textX}, {translateY: firstLineY}]} | ||
| width={merchantWidth} | ||
| height={BAR_HEIGHT} | ||
| /> | ||
| <SkeletonRect | ||
| transform={[{translateX: textX}, {translateY: secondLineY}]} | ||
| width={DATE_WIDTH} | ||
| height={BAR_HEIGHT} | ||
| /> | ||
| {/* Right-aligned, so they can only be placed once measured; a guessed position would visibly jump. */} | ||
| {containerWidth > 0 && ( | ||
| <> | ||
| <SkeletonRect | ||
| transform={[{translateX: containerWidth - AMOUNT_WIDTH}, {translateY: firstLineY}]} | ||
| width={AMOUNT_WIDTH} | ||
| height={BAR_HEIGHT} | ||
| /> | ||
| <SkeletonRect | ||
| transform={[{translateX: containerWidth - TYPE_WIDTH}, {translateY: secondLineY}]} | ||
| width={TYPE_WIDTH} | ||
| height={BAR_HEIGHT} | ||
| /> | ||
| </> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| if (!shouldShowSkeleton) { | ||
| return <EmptyState />; | ||
| } | ||
|
|
||
| return ( | ||
| <View | ||
| testID="recentlyAddedSkeleton" | ||
| style={shouldUseNarrowLayout ? styles.ph5 : styles.ph8} | ||
| > | ||
| {/* Measured without padding: the padded parent's width includes the inset, which pushes the right-aligned bars off the svg. */} | ||
| <View | ||
| style={styles.flex1} | ||
| onLayout={onLayout} | ||
| > | ||
| <ItemListSkeletonView | ||
| itemViewHeight={ITEM_HEIGHT} | ||
| fixedNumItems={CONST.HOME.SECTION_VISIBLE_LIMIT} | ||
| renderSkeletonItem={renderSkeletonItem} | ||
| /> | ||
| <View style={separatorsSpacerStyle} /> | ||
| </View> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default RecentlyAddedPlaceholder; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.