diff --git a/src/libs/focusComposerWithDelay/index.ts b/src/libs/focusComposerWithDelay/index.ts index cbd81b884d12..eef9d21d113d 100644 --- a/src/libs/focusComposerWithDelay/index.ts +++ b/src/libs/focusComposerWithDelay/index.ts @@ -31,7 +31,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. + setTimeout(() => textInput.focus(), 0); 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} />