From b44a77719740e8912fbac9eb23647302888a6a05 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Thu, 16 Nov 2023 00:04:38 -0600 Subject: [PATCH] fix:: not focus the composer when file picker is opened --- .../ReportActionCompose/ReportActionCompose.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js index c0a1151f0202..2f0ecfa493bd 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js @@ -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(); @@ -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; }, []); @@ -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}