diff --git a/src/libs/actions/InputFocus/index.desktop.ts b/src/libs/actions/InputFocus/index.desktop.ts index 2a8fe1b9fd01..07c5195cac42 100644 --- a/src/libs/actions/InputFocus/index.desktop.ts +++ b/src/libs/actions/InputFocus/index.desktop.ts @@ -1,3 +1,4 @@ +import {InteractionManager} from 'react-native'; import Onyx from 'react-native-onyx'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -18,7 +19,9 @@ function composerFocusKeepFocusOn(ref: HTMLElement, isFocused: boolean, modal: M } if (!isFocused && !onyxFocused && !modal.willAlertModalBecomeVisible && !modal.isVisible && refSave) { if (!ReportActionComposeFocusManager.isFocused()) { - refSave.focus(); + InteractionManager.runAfterInteractions(() => { + refSave?.focus(); + }); } else { refSave = undefined; } diff --git a/src/libs/actions/InputFocus/index.website.ts b/src/libs/actions/InputFocus/index.website.ts index 541254ac0cda..da60f5867132 100644 --- a/src/libs/actions/InputFocus/index.website.ts +++ b/src/libs/actions/InputFocus/index.website.ts @@ -1,3 +1,4 @@ +import {InteractionManager} from 'react-native'; import Onyx from 'react-native-onyx'; import * as Browser from '@libs/Browser'; import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager'; @@ -19,7 +20,10 @@ function composerFocusKeepFocusOn(ref: HTMLElement, isFocused: boolean, modal: M } if (!isFocused && !onyxFocused && !modal.willAlertModalBecomeVisible && !modal.isVisible && refSave) { if (!ReportActionComposeFocusManager.isFocused()) { - refSave.focus(); + // Focusing will fail when it is called immediately after closing modal so we call it after interaction. + InteractionManager.runAfterInteractions(() => { + refSave?.focus(); + }); } else { refSave = undefined; }