File tree 1 file changed +18
-1
lines changed
src/components/AttachmentPicker 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useRef } from 'react' ;
2
2
import CONST from '../../CONST' ;
3
3
import { propTypes , defaultProps } from './attachmentPickerPropTypes' ;
4
+ import Visibility from '../../libs/Visibility' ;
4
5
5
6
/**
6
7
* Returns acceptable FileTypes based on ATTACHMENT_PICKER_TYPE
@@ -53,7 +54,23 @@ function AttachmentPicker(props) {
53
54
if ( ! fileInput . current ) {
54
55
return ;
55
56
}
56
- fileInput . current . addEventListener ( 'cancel' , ( ) => onCanceled . current ( ) , { once : true } ) ;
57
+ fileInput . current . addEventListener (
58
+ 'cancel' ,
59
+ ( ) => {
60
+ // For Android Chrome, the cancel event happens before the page is visible on physical devices,
61
+ // which makes it unreliable for us to show the keyboard, while on emulators it happens after the page is visible.
62
+ // So here we can delay calling the onCanceled.current function based on visibility in order to reliably show the keyboard.
63
+ if ( Visibility . isVisible ( ) ) {
64
+ onCanceled . current ( ) ;
65
+ return ;
66
+ }
67
+ const unsubscribeVisibilityListener = Visibility . onVisibilityChange ( ( ) => {
68
+ onCanceled . current ( ) ;
69
+ unsubscribeVisibilityListener ( ) ;
70
+ } ) ;
71
+ } ,
72
+ { once : true } ,
73
+ ) ;
57
74
} }
58
75
accept = { getAcceptableFileTypes ( props . type ) }
59
76
/>
You can’t perform that action at this time.
0 commit comments