From bb9318f32d2aa5cd8b31d78b4a63dc98156bb434 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 29 Nov 2024 21:17:58 +0300 Subject: [PATCH 1/3] 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} /> From 99912ca80a4dfad558fa3879887d8207ddd2d690 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 3 Dec 2024 18:56:08 +0300 Subject: [PATCH 2/3] change to setTimeout --- src/libs/focusComposerWithDelay/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/focusComposerWithDelay/index.ts b/src/libs/focusComposerWithDelay/index.ts index 76c3c1e68837..5e85a8813561 100644 --- a/src/libs/focusComposerWithDelay/index.ts +++ b/src/libs/focusComposerWithDelay/index.ts @@ -33,7 +33,7 @@ function focusComposerWithDelay(textInput: InputType | null): FocusComposerWithD return; } // When the closing modal has a focused text input focus() needs a delay to properly work. - InteractionManager.runAfterInteractions(() => textInput.focus()); + setTimeout(() => textInput.focus(), 0); if (forcedSelectionRange) { setTextInputSelection(textInput, forcedSelectionRange); } From ad9bf4de156d215a0d0187a49ad9b8bfb240b66c Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 3 Dec 2024 19:06:05 +0300 Subject: [PATCH 3/3] remove unwanted import --- src/libs/focusComposerWithDelay/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/focusComposerWithDelay/index.ts b/src/libs/focusComposerWithDelay/index.ts index 5e85a8813561..eef9d21d113d 100644 --- a/src/libs/focusComposerWithDelay/index.ts +++ b/src/libs/focusComposerWithDelay/index.ts @@ -1,4 +1,3 @@ -import {InteractionManager} from 'react-native'; import ComposerFocusManager from '@libs/ComposerFocusManager'; import isWindowReadyToFocus from '@libs/isWindowReadyToFocus'; import * as EmojiPickerAction from '@userActions/EmojiPickerAction';