diff --git a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js index 5864b9b0502..6dd3355f4a5 100644 --- a/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js +++ b/src/pages/home/report/ReportActionCompose/AttachmentPickerWithMenuItems.js @@ -76,6 +76,9 @@ const propTypes = { /** Called when the add action button is pressed */ onAddActionPressed: PropTypes.func.isRequired, + /** Called when the menu item is selected */ + onItemSelected: PropTypes.func.isRequired, + /** A ref for the add action button */ actionButtonRef: PropTypes.shape({ // eslint-disable-next-line react/forbid-prop-types @@ -111,6 +114,7 @@ function AttachmentPickerWithMenuItems({ onCanceledAttachmentPicker, onMenuClosed, onAddActionPressed, + onItemSelected, actionButtonRef, }) { const {translate} = useLocalize(); @@ -257,6 +261,7 @@ function AttachmentPickerWithMenuItems({ onClose={onPopoverMenuClose} onItemSelected={(item, index) => { setMenuVisibility(false); + onItemSelected(); // In order for the file picker to open dynamically, the click // function must be called from within a event handler that was initiated diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js index da95fdf76b5..3b5b181d2fc 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js @@ -321,11 +321,11 @@ function ComposerWithSuggestions({ suggestionsRef.current.updateShouldShowSuggestionMenuToFalse(false); }, [suggestionsRef]); - const setShouldBlockSuggestionCalc = useCallback(() => { + const setShouldBlockSuggestionCalcToFalse = useCallback(() => { if (!suggestionsRef.current) { return false; } - return suggestionsRef.current.setShouldBlockSuggestionCalc(true); + return suggestionsRef.current.setShouldBlockSuggestionCalc(false); }, [suggestionsRef]); /** @@ -472,7 +472,7 @@ function ComposerWithSuggestions({ maxLines={maxComposerLines} onFocus={onFocus} onBlur={onBlur} - onClick={setShouldBlockSuggestionCalc} + onClick={setShouldBlockSuggestionCalcToFalse} onPasteFile={displayFileInModal} shouldClear={textInputShouldClear} onClear={() => setTextInputShouldClear(false)} diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js index 3ad92fa5c76..89ed9ded787 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js @@ -75,7 +75,6 @@ const propTypes = { }; const defaultProps = { - modal: {}, report: {}, blockedFromConcierge: {}, personalDetails: {}, @@ -205,6 +204,10 @@ function ReportActionCompose({ composerRef.current.blur(); }, []); + const onItemSelected = useCallback(() => { + isKeyboardVisibleWhenShowingModalRef.current = false; + }, []); + const updateShouldShowSuggestionMenuToFalse = useCallback(() => { if (!suggestionsRef.current) { return; @@ -271,6 +274,7 @@ function ReportActionCompose({ suggestionsRef.current.setShouldBlockSuggestionCalc(true); } isNextModalWillOpenRef.current = true; + isKeyboardVisibleWhenShowingModalRef.current = true; }, []); const onBlur = useCallback((e) => { @@ -358,6 +362,7 @@ function ReportActionCompose({ onCanceledAttachmentPicker={restoreKeyboardState} onMenuClosed={restoreKeyboardState} onAddActionPressed={onAddActionPressed} + onItemSelected={onItemSelected} actionButtonRef={actionButtonRef} />