Skip to content

Commit

Permalink
Merge pull request #37957 from dukenv0307/fix/37272
Browse files Browse the repository at this point in the history
Fix deleted characters display briefly after saving edited parent message
  • Loading branch information
roryabraham authored Mar 22, 2024
2 parents a59fd6d + bcb4663 commit 416c759
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 416c759

Please sign in to comment.