File tree Expand file tree Collapse file tree 3 files changed +71
-67
lines changed Expand file tree Collapse file tree 3 files changed +71
-67
lines changed Original file line number Diff line number Diff line change @@ -79,36 +79,35 @@ const Menu = (
79
79
return (
80
80
< >
81
81
{ updatedTrigger ( ) }
82
- { isOpen && (
83
- < Overlay
84
- isOpen = { isOpen }
85
- onRequestClose = { handleClose }
86
- useRNModalOnAndroid
87
- { ..._overlay }
88
- >
89
- < PresenceTransition visible = { isOpen } { ..._presenceTransition } >
90
- < Popper
91
- triggerRef = { triggerRef }
92
- onClose = { handleClose }
93
- placement = { placement }
94
- { ...resolvedProps }
95
- >
96
- < Backdrop onPress = { handleClose } { ..._backdrop } />
97
- < Popper . Content isOpen = { isOpen } >
98
- < MenuContext . Provider
99
- value = { { closeOnSelect, onClose : handleClose } }
100
- >
101
- < FocusScope contain restoreFocus autoFocus >
102
- < MenuContent menuRef = { ref } { ...resolvedProps } >
103
- { children }
104
- </ MenuContent >
105
- </ FocusScope >
106
- </ MenuContext . Provider >
107
- </ Popper . Content >
108
- </ Popper >
109
- </ PresenceTransition >
110
- </ Overlay >
111
- ) }
82
+ < Overlay
83
+ isOpen = { isOpen }
84
+ onRequestClose = { handleClose }
85
+ useRNModalOnAndroid
86
+ { ..._overlay }
87
+ unmountOnExit
88
+ >
89
+ < PresenceTransition visible = { isOpen } { ..._presenceTransition } >
90
+ < Popper
91
+ triggerRef = { triggerRef }
92
+ onClose = { handleClose }
93
+ placement = { placement }
94
+ { ...resolvedProps }
95
+ >
96
+ < Backdrop onPress = { handleClose } { ..._backdrop } />
97
+ < Popper . Content isOpen = { isOpen } >
98
+ < MenuContext . Provider
99
+ value = { { closeOnSelect, onClose : handleClose } }
100
+ >
101
+ < FocusScope contain restoreFocus autoFocus >
102
+ < MenuContent menuRef = { ref } { ...resolvedProps } >
103
+ { children }
104
+ </ MenuContent >
105
+ </ FocusScope >
106
+ </ MenuContext . Provider >
107
+ </ Popper . Content >
108
+ </ Popper >
109
+ </ PresenceTransition >
110
+ </ Overlay >
112
111
</ >
113
112
) ;
114
113
} ;
Original file line number Diff line number Diff line change @@ -73,44 +73,43 @@ const Popover = (
73
73
return (
74
74
< Box ref = { ref } >
75
75
{ updatedTrigger ( ) }
76
- { isOpen && (
77
- < Overlay
78
- isOpen = { isOpen }
79
- onRequestClose = { handleClose }
80
- useRNModalOnAndroid
76
+ < Overlay
77
+ isOpen = { isOpen }
78
+ onRequestClose = { handleClose }
79
+ useRNModalOnAndroid
80
+ unmountOnExit
81
+ >
82
+ < PresenceTransition
83
+ initial = { { opacity : 0 } }
84
+ animate = { { opacity : 1 , transition : { duration : 150 } } }
85
+ exit = { { opacity : 0 , scale : 0.95 , transition : { duration : 100 } } }
86
+ visible = { isOpen }
87
+ style = { StyleSheet . absoluteFill }
81
88
>
82
- < PresenceTransition
83
- initial = { { opacity : 0 } }
84
- animate = { { opacity : 1 , transition : { duration : 150 } } }
85
- exit = { { opacity : 0 , scale : 0.95 , transition : { duration : 100 } } }
86
- visible = { isOpen }
87
- style = { StyleSheet . absoluteFill }
88
- >
89
- < Popper onClose = { handleClose } triggerRef = { triggerRef } { ...props } >
90
- < Backdrop onPress = { handleClose } bg = "transparent" />
91
- < PopoverContext . Provider
92
- value = { {
93
- onClose : handleClose ,
94
- initialFocusRef,
95
- finalFocusRef,
96
- popoverContentId,
97
- bodyId,
98
- headerId,
99
- headerMounted,
100
- bodyMounted,
101
- setBodyMounted,
102
- setHeaderMounted,
103
- isOpen,
104
- } }
105
- >
106
- < FocusScope contain = { trapFocus } restoreFocus autoFocus >
107
- { children }
108
- </ FocusScope >
109
- </ PopoverContext . Provider >
110
- </ Popper >
111
- </ PresenceTransition >
112
- </ Overlay >
113
- ) }
89
+ < Popper onClose = { handleClose } triggerRef = { triggerRef } { ...props } >
90
+ < Backdrop onPress = { handleClose } bg = "transparent" />
91
+ < PopoverContext . Provider
92
+ value = { {
93
+ onClose : handleClose ,
94
+ initialFocusRef,
95
+ finalFocusRef,
96
+ popoverContentId,
97
+ bodyId,
98
+ headerId,
99
+ headerMounted,
100
+ bodyMounted,
101
+ setBodyMounted,
102
+ setHeaderMounted,
103
+ isOpen,
104
+ } }
105
+ >
106
+ < FocusScope contain = { trapFocus } restoreFocus autoFocus >
107
+ { children }
108
+ </ FocusScope >
109
+ </ PopoverContext . Provider >
110
+ </ Popper >
111
+ </ PresenceTransition >
112
+ </ Overlay >
114
113
</ Box >
115
114
) ;
116
115
} ;
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ export interface IOverlayProps {
15
15
isKeyboardDismissable ?: boolean ;
16
16
animationPreset ?: 'fade' | 'slide' | 'none' ;
17
17
style ?: ViewStyle ;
18
+ unmountOnExit ?: boolean ;
18
19
}
19
20
20
21
export function Overlay ( {
@@ -26,6 +27,7 @@ export function Overlay({
26
27
animationPreset = 'fade' ,
27
28
onRequestClose,
28
29
style,
30
+ unmountOnExit,
29
31
} : IOverlayProps ) {
30
32
const [ exited , setExited ] = React . useState ( ! isOpen ) ;
31
33
@@ -56,6 +58,10 @@ export function Overlay({
56
58
) ;
57
59
}
58
60
61
+ if ( unmountOnExit && ! isOpen && exited ) {
62
+ return null ;
63
+ }
64
+
59
65
return (
60
66
//@ts -ignore
61
67
< OverlayContainer style = { { ...styleObj } } >
You can’t perform that action at this time.
0 commit comments