-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Home Page] Design Followup for Recently Added Slot #95056
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
grgia
merged 7 commits into
Expensify:main
from
software-mansion-labs:@adamgrzybowski/recently-added-follow-ups
Jul 6, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
96b1b87
Anchor receipt hover preview to row and add WidgetHeaderMenu
adamgrzybowski 14b2579
Address PR review: clamp preview to viewport, rename WidgetHeaderMenu…
adamgrzybowski 5e4449d
Move AnchorPosition type to common TransactionItemRow types
adamgrzybowski 49d27c1
Merge branch 'main' into @adamgrzybowski/recently-added-follow-ups
adamgrzybowski 686cd8c
Run fmt
adamgrzybowski 5143e69
Build WidgetHeaderMenu on ThreeDotsMenu
adamgrzybowski 7a3557c
Fix RecentlyAddedSection overflow menu test hang
adamgrzybowski 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
51 changes: 51 additions & 0 deletions
51
src/components/TransactionItemRow/ReceiptPreview/getAnchoredPreviewPosition.ts
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,51 @@ | ||
| import type {AnchorPosition} from '@components/TransactionItemRow/types'; | ||
|
|
||
| import variables from '@styles/variables'; | ||
|
|
||
| /** Width of the preview, shared with `styles.receiptPreview.width` via `variables.receiptPreviewWidth`. */ | ||
| const RECEIPT_PREVIEW_WIDTH = variables.receiptPreviewWidth; | ||
|
|
||
| /** Horizontal gap between the hovered thumbnail and the preview. */ | ||
| const RECEIPT_PREVIEW_GAP = 16; | ||
|
|
||
| /** Gap kept between the preview and the viewport edges. */ | ||
| const RECEIPT_PREVIEW_EDGE_MARGIN = 24; | ||
|
|
||
| /** Minimum slice of the preview kept on-screen so a row near the bottom doesn't push it fully out of view. */ | ||
| const RECEIPT_PREVIEW_MIN_VISIBLE_HEIGHT = 160; | ||
|
|
||
| /** | ||
| * Anchors the preview's bottom-left corner to the right of the hovered thumbnail, so the preview grows upward | ||
| * from the row. If there isn't room on the right, it flips to the left of the thumbnail. The top is clamped to a | ||
| * viewport margin so a tall receipt near the top of the screen never runs off the top edge. Returns undefined | ||
| * when there is no anchor, so the caller keeps the static style. | ||
| * | ||
| * @param previewHeight Measured height of the preview. 0 means "not measured yet" — we can't bottom-align without | ||
| * it, so we fall back to aligning the top with the row (keeping a minimum slice on-screen) for the first frame. | ||
| */ | ||
| function getAnchoredPreviewPosition(anchorPosition: AnchorPosition | undefined, windowWidth: number, windowHeight: number, previewHeight = 0) { | ||
| if (!anchorPosition) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const rightOfThumbnail = anchorPosition.left + anchorPosition.width + RECEIPT_PREVIEW_GAP; | ||
| const overflowsRight = windowWidth > 0 && rightOfThumbnail + RECEIPT_PREVIEW_WIDTH + RECEIPT_PREVIEW_EDGE_MARGIN > windowWidth; | ||
| const left = overflowsRight ? Math.max(RECEIPT_PREVIEW_EDGE_MARGIN, anchorPosition.left - RECEIPT_PREVIEW_WIDTH - RECEIPT_PREVIEW_GAP) : rightOfThumbnail; | ||
|
|
||
| // Before it's measured we can't bottom-align, so keep a minimum slice on-screen relative to the row top. | ||
| if (previewHeight <= 0) { | ||
| const lowestTop = windowHeight - RECEIPT_PREVIEW_MIN_VISIBLE_HEIGHT; | ||
| return {left, top: Math.min(Math.max(anchorPosition.top, RECEIPT_PREVIEW_EDGE_MARGIN), Math.max(RECEIPT_PREVIEW_EDGE_MARGIN, lowestTop))}; | ||
| } | ||
|
|
||
| // Align the preview's bottom edge with the thumbnail's bottom (bottom-left corner sits at the thumbnail's | ||
| // right side). Cap the thumbnail bottom to the viewport so a row scrolled partially off the bottom doesn't | ||
| // push the preview below the screen, then clamp to the top margin so a tall preview stays on-screen. | ||
| const thumbnailBottom = Math.min(anchorPosition.top + anchorPosition.height, windowHeight - RECEIPT_PREVIEW_EDGE_MARGIN); | ||
| const top = Math.max(RECEIPT_PREVIEW_EDGE_MARGIN, thumbnailBottom - previewHeight); | ||
|
|
||
| return {left, top}; | ||
| } | ||
|
|
||
| export default getAnchoredPreviewPosition; | ||
| export {RECEIPT_PREVIEW_WIDTH, RECEIPT_PREVIEW_GAP, RECEIPT_PREVIEW_EDGE_MARGIN, RECEIPT_PREVIEW_MIN_VISIBLE_HEIGHT}; | ||
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
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.