-
Notifications
You must be signed in to change notification settings - Fork 3.9k
PopoverWithMeasuredContent optimization for mobile #68223
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 10 commits into
Expensify:main
from
software-mansion-labs:feat/popover-optimization-v2
Sep 11, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e779968
all the changes again
jmusial 55aadb2
Merge branch 'main' into feat/popover-optimization-v2
jmusial 1e3dcf1
Merge branch 'main' into feat/popover-optimization-v2
jmusial 919534b
Merge branch 'main' into feat/popover-optimization-v2
jmusial ffbe89c
remove the old file
jmusial 89798b0
Merge branch 'main' into feat/popover-optimization-v2
jmusial dddf62d
Merge branch 'main' into feat/popover-optimization-v2
jmusial f05cf46
Merge branch 'main' into feat/popover-optimization-v2
jmusial aa3dba8
revert merge leftover changes
jmusial 50015c4
Merge branch 'main' into feat/popover-optimization-v2
jmusial 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import {circularDeepEqual} from 'fast-equals'; | ||
| import React from 'react'; | ||
| import Modal from '@components/Modal'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import CONST from '@src/CONST'; | ||
| import PopoverWithMeasuredContentBase from './PopoverWithMeasuredContentBase'; | ||
| import type PopoverWithMeasuredContentProps from './types'; | ||
|
|
||
| /** | ||
| * Logic for PopoverWithMeasuredContent is in PopoverWithMeasuredContentBase. | ||
| * This component is a perf optimization, it return BOTTOM_DOCKED early, for small screens avoiding Popover measurement logic calculations. | ||
| */ | ||
| function PopoverWithMeasuredContent({...props}: PopoverWithMeasuredContentProps) { | ||
| // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth | ||
| const {isSmallScreenWidth} = useResponsiveLayout(); | ||
| if (isSmallScreenWidth) { | ||
| return ( | ||
| <Modal | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...props} | ||
| type={CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED} | ||
| animationIn="slideInUp" | ||
| animationOut="slideOutDown" | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| return <PopoverWithMeasuredContentBase {...props} />; | ||
| } | ||
| PopoverWithMeasuredContent.displayName = 'PopoverWithMeasuredContent'; | ||
|
|
||
| export default React.memo(PopoverWithMeasuredContent, (prevProps, nextProps) => { | ||
| if (prevProps.isVisible === nextProps.isVisible && nextProps.isVisible === false) { | ||
| return true; | ||
| } | ||
| return circularDeepEqual(prevProps, nextProps); | ||
| }); | ||
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,24 @@ | ||
| import type PopoverProps from '@components/Popover/types'; | ||
| import type {AnchorDimensions, AnchorPosition} from '@styles/index'; | ||
|
|
||
| type PopoverWithMeasuredContentProps = Omit<PopoverProps, 'anchorPosition'> & { | ||
| /** The horizontal and vertical anchors points for the popover */ | ||
| anchorPosition: AnchorPosition; | ||
|
|
||
| /** The dimension of anchor component */ | ||
| anchorDimensions?: AnchorDimensions; | ||
|
|
||
| /** Whether we should change the vertical position if the popover's position is overflow */ | ||
| shouldSwitchPositionIfOverflow?: boolean; | ||
|
|
||
| /** Whether handle navigation back when modal show. */ | ||
| shouldHandleNavigationBack?: boolean; | ||
|
|
||
| /** Whether we should should use top side for the anchor positioning */ | ||
| shouldMeasureAnchorPositionFromTop?: boolean; | ||
|
|
||
| /** Whether to skip re-measurement when becoming visible (for components with static dimensions) */ | ||
| shouldSkipRemeasurement?: boolean; | ||
| }; | ||
|
|
||
| export default PopoverWithMeasuredContentProps; |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this reads better