Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reopen keyboard when tap back on gallery page. #26221

Merged
merged 5 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/components/AttachmentPicker/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useRef} from 'react';
import CONST from '../../CONST';
import {propTypes, defaultProps} from './attachmentPickerPropTypes';
import Visibility from '../../libs/Visibility';

/**
* Returns acceptable FileTypes based on ATTACHMENT_PICKER_TYPE
Expand Down Expand Up @@ -53,7 +54,23 @@ function AttachmentPicker(props) {
if (!fileInput.current) {
return;
}
fileInput.current.addEventListener('cancel', () => onCanceled.current(), {once: true});
fileInput.current.addEventListener(
'cancel',
() => {
// For Android Chrome, the cancel event happens before the page is visible on physical devices,
// which makes it unreliable for us to show the keyboard, while on emulators it happens after the page is visible.
// So here we can delay calling the onCanceled.current function based on visibility in order to reliably show the keyboard.
if (Visibility.isVisible()) {
onCanceled.current();
return;
}
const unsubscribeVisibilityListener = Visibility.onVisibilityChange(() => {
onCanceled.current();
unsubscribeVisibilityListener();
});
ntdiary marked this conversation as resolved.
Show resolved Hide resolved
},
{once: true},
);
}}
accept={getAcceptableFileTypes(props.type)}
/>
Expand Down
Loading