From bcb4663fc1c601f948dcd369020ad3198d115710 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 8 Mar 2024 17:53:54 +0700 Subject: [PATCH] Fix deleted characters display briefly after saving edited parent message --- src/pages/home/report/ReportActionItemMessageEdit.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItemMessageEdit.tsx b/src/pages/home/report/ReportActionItemMessageEdit.tsx index fbf2da69aa31..b5c18976aa86 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.tsx +++ b/src/pages/home/report/ReportActionItemMessageEdit.tsx @@ -17,6 +17,7 @@ import Tooltip from '@components/Tooltip'; import useHandleExceedMaxCommentLength from '@hooks/useHandleExceedMaxCommentLength'; import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; +import usePrevious from '@hooks/usePrevious'; import useReportScrollManager from '@hooks/useReportScrollManager'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; @@ -79,6 +80,7 @@ function ReportActionItemMessageEdit( const {translate, preferredLocale} = useLocalize(); const {isKeyboardShown} = useKeyboardState(); const {isSmallScreenWidth} = useWindowDimensions(); + const prevDraftMessage = usePrevious(draftMessage); const getInitialDraft = () => { if (draftMessage === action?.message?.[0].html) { @@ -124,11 +126,11 @@ function ReportActionItemMessageEdit( const draftRef = useRef(draft); useEffect(() => { - if (ReportActionsUtils.isDeletedAction(action) || (action.message && draftMessage === action.message[0].html)) { + if (ReportActionsUtils.isDeletedAction(action) || Boolean(action.message && draftMessage === action.message[0].html) || Boolean(prevDraftMessage === draftMessage)) { return; } setDraft(Str.htmlDecode(draftMessage)); - }, [draftMessage, action]); + }, [draftMessage, action, prevDraftMessage]); useEffect(() => { // required for keeping last state of isFocused variable