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

fix:: not focus the composer when file picker is opened #31421

Merged
merged 4 commits into from
Dec 4, 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
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ function ReportActionCompose({
};

const isKeyboardVisibleWhenShowingModalRef = useRef(false);
const isNextModalWillOpenRef = useRef(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to understand how this works. We are not setting this ref to true anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check. We set true when next modal will open

isNextModalWillOpenRef.current = true;

const restoreKeyboardState = useCallback(() => {
if (!isKeyboardVisibleWhenShowingModalRef.current) {
if (!isKeyboardVisibleWhenShowingModalRef.current || isNextModalWillOpenRef.current) {
return;
}
focus();
Expand Down Expand Up @@ -265,13 +266,7 @@ function ReportActionCompose({
[onSubmit],
);

const isNextModalWillOpenRef = useRef(false);
const onTriggerAttachmentPicker = useCallback(() => {
// Set a flag to block suggestion calculation until we're finished using the file picker,
// which will stop any flickering as the file picker opens on non-native devices.
if (willBlurTextInputOnTapOutside) {
suggestionsRef.current.setShouldBlockSuggestionCalc(true);
}
isNextModalWillOpenRef.current = true;
isKeyboardVisibleWhenShowingModalRef.current = true;
}, []);
Expand Down Expand Up @@ -379,7 +374,10 @@ function ReportActionCompose({
setMenuVisibility={setMenuVisibility}
isMenuVisible={isMenuVisible}
onTriggerAttachmentPicker={onTriggerAttachmentPicker}
onCanceledAttachmentPicker={restoreKeyboardState}
onCanceledAttachmentPicker={() => {
isNextModalWillOpenRef.current = false;
restoreKeyboardState();
}}
onMenuClosed={restoreKeyboardState}
onAddActionPressed={onAddActionPressed}
onItemSelected={onItemSelected}
Expand Down
Loading