From 9005a8a3faa69cebbc472b6512df67a7b85eadbe Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 22 Aug 2023 01:42:27 +0700 Subject: [PATCH] only clear in case of edit composer --- src/components/Composer/index.js | 9 ++++++++- src/libs/ReportActionComposeFocusManager.js | 2 +- src/pages/home/report/ReportActionCompose.js | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index aad965ff536b..dc9b5ba4ac67 100755 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -80,6 +80,9 @@ const propTypes = { /** Function to check whether composer is covered up or not */ checkComposerVisibility: PropTypes.func, + /** Whether this is the report action compose */ + isReportActionCompose: PropTypes.bool, + ...withLocalizePropTypes, ...windowDimensionsPropTypes, @@ -107,6 +110,7 @@ const defaultProps = { setIsFullComposerAvailable: () => {}, shouldCalculateCaretPosition: false, checkComposerVisibility: () => false, + isReportActionCompose: false, }; /** @@ -156,6 +160,7 @@ function Composer({ setIsFullComposerAvailable, checkComposerVisibility, selection: selectionProp, + isReportActionCompose, ...props }) { const textRef = useRef(null); @@ -371,7 +376,9 @@ function Composer({ } return () => { - ReportActionComposeFocusManager.clear(); + if (!isReportActionCompose) { + ReportActionComposeFocusManager.clear(); + } unsubscribeFocus(); unsubscribeBlur(); document.removeEventListener('paste', handlePaste); diff --git a/src/libs/ReportActionComposeFocusManager.js b/src/libs/ReportActionComposeFocusManager.js index 025a46ade894..7f31b17aaa57 100644 --- a/src/libs/ReportActionComposeFocusManager.js +++ b/src/libs/ReportActionComposeFocusManager.js @@ -47,7 +47,7 @@ function focus() { function clear(isMainComposer = false) { if (isMainComposer) { mainComposerFocusCallback = null; - } else if (mainComposerFocusCallback) { + } else { focusCallback = null; } } diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index a388b75efad5..675fab95ff28 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -1197,6 +1197,7 @@ function ReportActionCompose({ shouldClear={textInputShouldClear} onClear={() => setTextInputShouldClear(false)} isDisabled={isBlockedFromConcierge || disabled} + isReportActionCompose selection={selection} onSelectionChange={onSelectionChange} isFullComposerAvailable={isFullSizeComposerAvailable}