From bb9318f32d2aa5cd8b31d78b4a63dc98156bb434 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 29 Nov 2024 21:17:58 +0300 Subject: [PATCH] fix composer focus regain --- src/libs/focusComposerWithDelay/index.ts | 4 +++- .../home/report/ReportActionCompose/ReportActionCompose.tsx | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libs/focusComposerWithDelay/index.ts b/src/libs/focusComposerWithDelay/index.ts index cbd81b884d12..76c3c1e68837 100644 --- a/src/libs/focusComposerWithDelay/index.ts +++ b/src/libs/focusComposerWithDelay/index.ts @@ -1,3 +1,4 @@ +import {InteractionManager} from 'react-native'; import ComposerFocusManager from '@libs/ComposerFocusManager'; import isWindowReadyToFocus from '@libs/isWindowReadyToFocus'; import * as EmojiPickerAction from '@userActions/EmojiPickerAction'; @@ -31,7 +32,8 @@ function focusComposerWithDelay(textInput: InputType | null): FocusComposerWithD if (!textInput) { return; } - textInput.focus(); + // When the closing modal has a focused text input focus() needs a delay to properly work. + InteractionManager.runAfterInteractions(() => textInput.focus()); if (forcedSelectionRange) { setTextInputSelection(textInput, forcedSelectionRange); } diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index 59d1b4c00683..7634a5317eac 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -462,6 +462,12 @@ function ReportActionCompose({ raiseIsScrollLikelyLayoutTriggered={raiseIsScrollLikelyLayoutTriggered} onAddActionPressed={onAddActionPressed} onItemSelected={onItemSelected} + onCanceledAttachmentPicker={() => { + if (!shouldFocusInputOnScreenFocus) { + return; + } + focus(); + }} actionButtonRef={actionButtonRef} shouldDisableAttachmentItem={hasExceededMaxCommentLength} />