1- import { deepEqual } from 'fast-equals' ;
1+ import { circularDeepEqual , deepEqual } from 'fast-equals' ;
22import React , { useContext , useEffect , useMemo , useState } from 'react' ;
33import type { LayoutChangeEvent } from 'react-native' ;
44import { View } from 'react-native' ;
5- import * as ActionSheetAwareScrollView from '@components/ActionSheetAwareScrollView' ;
6- import type { PopoverAnchorPosition } from '@components/Modal/types' ;
7- import Popover from '@components/Popover' ;
85import usePrevious from '@hooks/usePrevious' ;
96import useThemeStyles from '@hooks/useThemeStyles' ;
107import useWindowDimensions from '@hooks/useWindowDimensions' ;
118import ComposerFocusManager from '@libs/ComposerFocusManager' ;
129import PopoverWithMeasuredContentUtils from '@libs/PopoverWithMeasuredContentUtils' ;
1310import CONST from '@src/CONST' ;
14- import type { PopoverWithMeasuredContentProps } from './types' ;
11+ import type { AnchorDimensions , AnchorPosition } from '@src/styles' ;
12+ import * as ActionSheetAwareScrollView from './ActionSheetAwareScrollView' ;
13+ import type { PopoverAnchorPosition } from './Modal/types' ;
14+ import Popover from './Popover' ;
15+ import type PopoverProps from './Popover/types' ;
16+
17+ type PopoverWithMeasuredContentProps = Omit < PopoverProps , 'anchorPosition' > & {
18+ /** The horizontal and vertical anchors points for the popover */
19+ anchorPosition : AnchorPosition ;
20+
21+ /** The dimension of anchor component */
22+ anchorDimensions ?: AnchorDimensions ;
23+
24+ /** Whether we should change the vertical position if the popover's position is overflow */
25+ shouldSwitchPositionIfOverflow ?: boolean ;
26+
27+ /** Whether handle navigation back when modal show. */
28+ shouldHandleNavigationBack ?: boolean ;
29+
30+ /** Whether we should should use top side for the anchor positioning */
31+ shouldMeasureAnchorPositionFromTop ?: boolean ;
32+
33+ /** Whether to skip re-measurement when becoming visible (for components with static dimensions) */
34+ shouldSkipRemeasurement ?: boolean ;
35+ } ;
1536
1637/**
1738 * This is a convenient wrapper around the regular Popover component that allows us to use a more sophisticated
@@ -20,7 +41,7 @@ import type {PopoverWithMeasuredContentProps} from './types';
2041 * anchor position.
2142 */
2243
23- function PopoverWithMeasuredContentBase ( {
44+ function PopoverWithMeasuredContent ( {
2445 popoverDimensions = {
2546 height : 0 ,
2647 width : 0 ,
@@ -210,10 +231,17 @@ function PopoverWithMeasuredContentBase({
210231 style = { styles . invisiblePopover }
211232 onLayout = { measurePopover }
212233 >
213- { ( isVisible || prevIsVisible ) && children }
234+ { children }
214235 </ View >
215236 ) ;
216237}
217- PopoverWithMeasuredContentBase . displayName = 'PopoverWithMeasuredContentBase' ;
238+ PopoverWithMeasuredContent . displayName = 'PopoverWithMeasuredContent' ;
239+
240+ export default React . memo ( PopoverWithMeasuredContent , ( prevProps , nextProps ) => {
241+ if ( prevProps . isVisible === nextProps . isVisible && nextProps . isVisible === false ) {
242+ return true ;
243+ }
244+ return circularDeepEqual ( prevProps , nextProps ) ;
245+ } ) ;
218246
219- export default PopoverWithMeasuredContentBase ;
247+ export type { PopoverWithMeasuredContentProps } ;
0 commit comments