Skip to content

Commit

Permalink
fix:: not focus the composer when file picker is opened
Browse files Browse the repository at this point in the history
  • Loading branch information
sangar-1028 committed Nov 16, 2023
1 parent 47c7819 commit b44a777
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/pages/home/report/ReportActionCompose/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ function ReportActionCompose({
};

const isKeyboardVisibleWhenShowingModalRef = useRef(false);
const isNextModalWillOpenRef = useRef(false);
const restoreKeyboardState = useCallback(() => {
if (!isKeyboardVisibleWhenShowingModalRef.current) {
if (!isKeyboardVisibleWhenShowingModalRef.current || isNextModalWillOpenRef.current) {
return;
}
focus();
Expand Down Expand Up @@ -270,13 +271,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 @@ -384,7 +379,10 @@ function ReportActionCompose({
setMenuVisibility={setMenuVisibility}
isMenuVisible={isMenuVisible}
onTriggerAttachmentPicker={onTriggerAttachmentPicker}
onCanceledAttachmentPicker={restoreKeyboardState}
onCanceledAttachmentPicker={() => {
isNextModalWillOpenRef.current = false;
restoreKeyboardState();
}}
onMenuClosed={restoreKeyboardState}
onAddActionPressed={onAddActionPressed}
onItemSelected={onItemSelected}
Expand Down

0 comments on commit b44a777

Please sign in to comment.