Skip to content
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
Copy Markdown
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
Copy Markdown
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