1
- // For stories, all popups using FloatingMenu will need to have a PropProvider
2
- // decorator added to the story. This is because FloatingMenus are rendered
3
- // into a GatewayDest component in a storybook context. GatewayDest is only
4
- // rendered if a PropProvider decorated is used. This is done so that connected
5
- // components inside of a popup have access to the mocked out Provider component
6
-
7
1
import * as React from 'react'
8
2
import Overlay from '../overlay'
9
3
import { Box2 } from '@/common-adapters/box'
@@ -21,6 +15,7 @@ import {
21
15
import { useSafeAreaInsets } from '@/common-adapters/safe-area-view'
22
16
import { FloatingModalContext } from './context'
23
17
import { FullWindowOverlay } from 'react-native-screens'
18
+ import { useNavigation } from '@react-navigation/native'
24
19
25
20
const Kb = {
26
21
Box2,
@@ -67,12 +62,22 @@ const FullWindow = ({children}: {children?: React.ReactNode}): React.ReactNode =
67
62
const defaultSnapPoints = [ '75%' ]
68
63
69
64
const FloatingMenu = React . memo ( function FloatingMenu ( props : Props ) {
70
- const { snapPoints, items, visible} = props
65
+ const { snapPoints, items, visible, onHidden } = props
71
66
const isModal = React . useContext ( FloatingModalContext )
72
67
const shownRef = React . useRef ( false )
73
68
74
69
const bottomRef = React . useRef < BottomSheetModal | null > ( null )
75
70
71
+ const navigation = useNavigation ( )
72
+
73
+ React . useEffect ( ( ) => {
74
+ const unsub = navigation . addListener ( 'state' , ( ) => {
75
+ bottomRef . current ?. forceClose ( )
76
+ onHidden ( )
77
+ } )
78
+ return unsub
79
+ } , [ bottomRef , navigation , onHidden ] )
80
+
76
81
React . useEffect ( ( ) => {
77
82
return ( ) => {
78
83
bottomRef . current ?. forceClose ( )
@@ -138,7 +143,7 @@ const FloatingMenu = React.memo(function FloatingMenu(props: Props) {
138
143
< Kb . Overlay
139
144
position = { props . position }
140
145
positionFallbacks = { props . positionFallbacks }
141
- onHidden = { props . onHidden }
146
+ onHidden = { onHidden }
142
147
visible = { props . visible }
143
148
attachTo = { props . attachTo }
144
149
remeasureHint = { props . remeasureHint }
0 commit comments