Skip to content

Commit

Permalink
Fix deleted characters display briefly after saving edited parent mes…
Browse files Browse the repository at this point in the history
…sage
  • Loading branch information
dukenv0307 committed Mar 8, 2024
1 parent 86a9904 commit bcb4663
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pages/home/report/ReportActionItemMessageEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bcb4663

Please sign in to comment.