1- import React , { useState } from 'react' ;
2- import type { RefObject } from 'react' ;
1+ import React , { Activity , useState } from 'react' ;
2+ import type { ActivityProps , RefObject } from 'react' ;
33import { View } from 'react-native' ;
44import FocusTrapForModal from '@components/FocusTrap/FocusTrapForModal' ;
55import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent' ;
@@ -40,13 +40,7 @@ function FABPopoverMenu({isVisible, onClose, onItemSelected, anchorRef, animatio
4040 const { shouldUseNarrowLayout} = useResponsiveLayout ( ) ;
4141 const { windowHeight} = useWindowDimensions ( ) ;
4242 const anchorPosition = styles . createMenuPositionSidebar ( windowHeight ) ;
43-
44- // Keep children mounted during the close animation so the fade-out is visible.
45- // Mount when isVisible becomes true; unmount only after the modal hide animation completes.
46- const [ shouldRenderChildren , setShouldRenderChildren ] = useState ( isVisible ) ;
47- if ( isVisible && ! shouldRenderChildren ) {
48- setShouldRenderChildren ( true ) ;
49- }
43+ const [ contentActivityMode , setContentActivityMode ] = useState < ActivityProps [ 'mode' ] > ( isVisible ? 'visible' : 'hidden' ) ;
5044
5145 const [ registeredSet , setRegisteredSet ] = useState < ReadonlySet < string > > ( new Set ( ) ) ;
5246
@@ -119,12 +113,13 @@ function FABPopoverMenu({isVisible, onClose, onItemSelected, anchorRef, animatio
119113 } }
120114 onClose = { handleClose }
121115 isVisible = { isVisible }
116+ onModalWillShow = { ( ) => setContentActivityMode ( 'visible' ) }
117+ onModalHide = { ( ) => setContentActivityMode ( 'hidden' ) }
122118 fromSidebarMediumScreen = { ! shouldUseNarrowLayout }
123119 animationIn = "fadeIn"
124120 animationOut = "fadeOut"
125121 animationInTiming = { animationInTiming }
126122 animationOutTiming = { animationOutTiming }
127- onModalHide = { ( ) => setShouldRenderChildren ( false ) }
128123 disableAnimation = { false }
129124 shouldHandleNavigationBack
130125 innerContainerStyle = { styles . pv0 }
@@ -133,9 +128,11 @@ function FABPopoverMenu({isVisible, onClose, onItemSelected, anchorRef, animatio
133128 active = { isVisible }
134129 shouldReturnFocus
135130 >
136- < View style = { shouldUseNarrowLayout ? styles . flexGrow1 : [ styles . createMenuContainer , styles . pv0 , styles . flex1 ] } >
137- < View style = { styles . pv4 } > { shouldRenderChildren ? children : null } </ View >
138- </ View >
131+ < Activity mode = { contentActivityMode } >
132+ < View style = { shouldUseNarrowLayout ? styles . flexGrow1 : [ styles . createMenuContainer , styles . pv0 , styles . flex1 ] } >
133+ < View style = { styles . pv4 } > { children } </ View >
134+ </ View >
135+ </ Activity >
139136 </ FocusTrapForModal >
140137 </ PopoverWithMeasuredContent >
141138 </ FABMenuContext . Provider >
0 commit comments