@@ -33,6 +33,25 @@ const Authentication = (props: {
3333 const [ passwordVisibility , setPasswordVisibility ] = useState ( false ) ;
3434 const [ biometricsAvailable , setBiometricsAvailable ] = useState ( false ) ;
3535 const [ setupBiometrics , setSetupBiometrics ] = useState ( false ) ;
36+ const [ modalVisible , setModalVisible ] = useState ( true ) ;
37+ // Guards against the success setTimeout (queued before the user tapped
38+ // cancel) firing after a cancel propagation already started, which
39+ // would otherwise call actionStatus(true) seconds after actionStatus(false).
40+ const propagated = useRef ( false ) ;
41+
42+ // Fade out the modal before the parent unmounts us. Without this, an
43+ // abrupt unmount during the same render commit (e.g. Home setting
44+ // submittingTransaction=true on approve) leaves iOS Fabric to take an
45+ // empty snapshot of the dismissed view, blanketing the screen with a
46+ // black overlay that can also block touches until the app is restarted.
47+ const propagate = ( status : boolean ) => {
48+ if ( propagated . current ) return ;
49+ propagated . current = true ;
50+ setModalVisible ( false ) ;
51+ setTimeout ( ( ) => {
52+ props . actionStatus ( status ) ;
53+ } , 300 ) ;
54+ } ;
3655
3756 useEffect ( ( ) => {
3857 if ( ! props . biomatricsAllowed ) {
@@ -110,7 +129,7 @@ const Authentication = (props: {
110129 if ( data && data . password ) {
111130 setPassword ( '' ) ;
112131 setPasswordVisibility ( false ) ;
113- props . actionStatus ( true ) ;
132+ propagate ( true ) ;
114133 } else {
115134 // biometrics failed, were tempered with, disable biometrics option and only allow for password authentication
116135 setPassword ( '' ) ;
@@ -139,7 +158,7 @@ const Authentication = (props: {
139158 console . log ( 'Close' ) ;
140159 setPassword ( '' ) ;
141160 setPasswordVisibility ( false ) ;
142- props . actionStatus ( false ) ;
161+ propagate ( false ) ;
143162 } ;
144163
145164 const grantAccess = async ( ) => {
@@ -222,7 +241,7 @@ const Authentication = (props: {
222241 setPassword ( '' ) ;
223242 setPasswordVisibility ( false ) ;
224243 setSetupBiometrics ( false ) ;
225- props . actionStatus ( true ) ;
244+ propagate ( true ) ;
226245 } catch ( error ) {
227246 console . log ( error ) ;
228247 displayMessage ( 'error' , t ( 'home:err_auth_pw_check' ) ) ;
@@ -237,7 +256,7 @@ const Authentication = (props: {
237256 < Modal
238257 animationType = "fade"
239258 transparent = { true }
240- visible = { true }
259+ visible = { modalVisible }
241260 onRequestClose = { ( ) => close ( ) }
242261 >
243262 < BlurOverlay />
0 commit comments