@@ -41,9 +41,22 @@ type ModalComponentProps = (ReactNativeModalProps | ReanimatedModalProps) & {
4141 shouldPreventScrollOnFocus ?: boolean ;
4242 initialFocus ?: FocusTrapOptions [ 'initialFocus' ] ;
4343 isVisible : boolean ;
44+ isKeyboardActive : boolean ;
45+ saveFocusState : ( ) => void ;
4446} ;
4547
46- function ModalComponent ( { type, shouldUseReanimatedModal, isVisible, shouldPreventScrollOnFocus, initialFocus, children, ...props } : ModalComponentProps ) {
48+ function ModalComponent ( {
49+ type,
50+ shouldUseReanimatedModal,
51+ isVisible,
52+ shouldPreventScrollOnFocus,
53+ initialFocus,
54+ children,
55+ saveFocusState,
56+ onDismiss = ( ) => { } ,
57+ isKeyboardActive,
58+ ...props
59+ } : ModalComponentProps ) {
4760 // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
4861 if ( ( type && REANIMATED_MODAL_TYPES . includes ( type ) ) || shouldUseReanimatedModal ) {
4962 return (
@@ -54,8 +67,15 @@ function ModalComponent({type, shouldUseReanimatedModal, isVisible, shouldPreven
5467 isVisible = { isVisible }
5568 shouldPreventScrollOnFocus = { shouldPreventScrollOnFocus }
5669 initialFocus = { initialFocus }
70+ onDismiss = { onDismiss }
5771 >
58- { children }
72+ < ModalContent
73+ onModalWillShow = { saveFocusState }
74+ onDismiss = { onDismiss }
75+ >
76+ { children }
77+ </ ModalContent >
78+ { ! isKeyboardActive && < NavigationBar /> }
5979 </ ReanimatedModal >
6080 ) ;
6181 }
@@ -65,14 +85,21 @@ function ModalComponent({type, shouldUseReanimatedModal, isVisible, shouldPreven
6585 // eslint-disable-next-line react/jsx-props-no-spreading
6686 { ...( props as ReactNativeModalProps ) }
6787 isVisible = { isVisible }
88+ onDismiss = { onDismiss }
6889 >
69- < FocusTrapForModal
70- active = { isVisible }
71- initialFocus = { initialFocus }
72- shouldPreventScroll = { shouldPreventScrollOnFocus }
90+ < ModalContent
91+ onModalWillShow = { saveFocusState }
92+ onDismiss = { onDismiss }
7393 >
74- { children }
75- </ FocusTrapForModal >
94+ < FocusTrapForModal
95+ active = { isVisible }
96+ initialFocus = { initialFocus }
97+ shouldPreventScroll = { shouldPreventScrollOnFocus }
98+ >
99+ { children }
100+ </ FocusTrapForModal >
101+ </ ModalContent >
102+ { ! isKeyboardActive && < NavigationBar /> }
76103 </ ReactNativeModal >
77104 ) ;
78105}
@@ -427,20 +454,16 @@ function BaseModal(
427454 customBackdrop = { shouldUseCustomBackdrop ? < Overlay onPress = { handleBackdropPress } /> : undefined }
428455 type = { type }
429456 shouldUseReanimatedModal = { shouldUseReanimatedModal }
457+ isKeyboardActive = { keyboardStateContextValue ?. isKeyboardActive }
458+ saveFocusState = { saveFocusState }
430459 >
431- < ModalContent
432- onModalWillShow = { saveFocusState }
433- onDismiss = { handleDismissModal }
460+ < Animated . View
461+ onLayout = { onViewLayout }
462+ style = { [ styles . defaultModalContainer , modalContainerStyle , modalPaddingStyles , ! isVisible && styles . pointerEventsNone , sidePanelReanimatedStyle ] }
463+ ref = { ref }
434464 >
435- < Animated . View
436- onLayout = { onViewLayout }
437- style = { [ styles . defaultModalContainer , modalContainerStyle , modalPaddingStyles , ! isVisible && styles . pointerEventsNone , sidePanelReanimatedStyle ] }
438- ref = { ref }
439- >
440- < ColorSchemeWrapper > { children } </ ColorSchemeWrapper >
441- </ Animated . View >
442- </ ModalContent >
443- { ! keyboardStateContextValue ?. isKeyboardActive && < NavigationBar /> }
465+ < ColorSchemeWrapper > { children } </ ColorSchemeWrapper >
466+ </ Animated . View >
444467 </ ModalComponent >
445468 </ View >
446469 </ ScreenWrapperOfflineIndicatorContext . Provider >
0 commit comments