@@ -4,11 +4,14 @@ import PropTypes from 'prop-types';
4
4
import { View } from 'react-native' ;
5
5
import { withNavigation } from '@react-navigation/compat' ;
6
6
import { SafeAreaInsetsContext } from 'react-native-safe-area-context' ;
7
+ import { withOnyx } from 'react-native-onyx' ;
7
8
import styles , { getSafeAreaPadding } from '../styles/styles' ;
8
9
import HeaderGap from './HeaderGap' ;
9
10
import KeyboardShortcut from '../libs/KeyboardShortcut' ;
10
11
import onScreenTransitionEnd from '../libs/onScreenTransitionEnd' ;
11
12
import Navigation from '../libs/Navigation/Navigation' ;
13
+ import compose from '../libs/compose' ;
14
+ import ONYXKEYS from '../ONYXKEYS' ;
12
15
13
16
const propTypes = {
14
17
/** Array of additional styles to add */
@@ -34,6 +37,13 @@ const propTypes = {
34
37
// Method to attach listener to Navigation state.
35
38
addListener : PropTypes . func . isRequired ,
36
39
} ) ,
40
+
41
+ /** Details about any modals being used */
42
+ modal : PropTypes . shape ( {
43
+ /** Indicates when an Alert modal is about to be visible */
44
+ willAlertModalBecomeVisible : PropTypes . bool ,
45
+ } ) ,
46
+
37
47
} ;
38
48
39
49
const defaultProps = {
@@ -44,6 +54,7 @@ const defaultProps = {
44
54
navigation : {
45
55
addListener : ( ) => { } ,
46
56
} ,
57
+ modal : { } ,
47
58
} ;
48
59
49
60
class ScreenWrapper extends React . Component {
@@ -56,7 +67,9 @@ class ScreenWrapper extends React.Component {
56
67
57
68
componentDidMount ( ) {
58
69
this . unsubscribeEscapeKey = KeyboardShortcut . subscribe ( 'Escape' , ( ) => {
59
- Navigation . dismissModal ( ) ;
70
+ if ( ! this . props . modal . willAlertModalBecomeVisible ) {
71
+ Navigation . dismissModal ( ) ;
72
+ }
60
73
} , [ ] , true ) ;
61
74
62
75
this . unsubscribeTransitionEnd = onScreenTransitionEnd ( this . props . navigation , ( ) => {
@@ -116,4 +129,11 @@ class ScreenWrapper extends React.Component {
116
129
ScreenWrapper . propTypes = propTypes ;
117
130
ScreenWrapper . defaultProps = defaultProps ;
118
131
ScreenWrapper . displayName = 'ScreenWrapper' ;
119
- export default withNavigation ( ScreenWrapper ) ;
132
+ export default compose (
133
+ withNavigation ,
134
+ withOnyx ( {
135
+ modal : {
136
+ key : ONYXKEYS . MODAL ,
137
+ } ,
138
+ } ) ,
139
+ ) ( ScreenWrapper ) ;
0 commit comments