From 7f72de44a4ff6a968fba0e8b9e853130886df794 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 18 Sep 2023 22:27:42 +0800 Subject: [PATCH] cancel save draft debounce before clearing composer --- .../ReportActionCompose/ComposerWithSuggestions.js | 5 +++++ .../report/ReportActionCompose/ReportActionCompose.js | 10 ---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js index 04757b0ff276..a73dd7c3d5db 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js @@ -241,6 +241,11 @@ function ComposerWithSuggestions({ return ''; } + // Since we're submitting the form here which should clear the composer + // We don't really care about saving the draft the user was typing + // We need to make sure an empty draft gets saved instead + debouncedSaveReportComment.cancel(); + updateComment(''); setTextInputShouldClear(true); if (isComposerFullSize) { diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js index ddcd43cd8cd0..c5179290bf2c 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js @@ -30,7 +30,6 @@ import OfflineWithFeedback from '../../../../components/OfflineWithFeedback'; import SendButton from './SendButton'; import AttachmentPickerWithMenuItems from './AttachmentPickerWithMenuItems'; import ComposerWithSuggestions from './ComposerWithSuggestions'; -import debouncedSaveReportComment from '../../../../libs/ComposerUtils/debouncedSaveReportComment'; import reportActionPropTypes from '../reportActionPropTypes'; import useLocalize from '../../../../hooks/useLocalize'; import getModalState from '../../../../libs/getModalState'; @@ -220,10 +219,6 @@ function ReportActionCompose({ */ const addAttachment = useCallback( (file) => { - // Since we're submitting the form here which should clear the composer - // We don't really care about saving the draft the user was typing - // We need to make sure an empty draft gets saved instead - debouncedSaveReportComment.cancel(); const newComment = composerRef.current.prepareCommentAndResetComposer(); Report.addAttachment(reportID, file, newComment); setTextInputShouldClear(false); @@ -251,11 +246,6 @@ function ReportActionCompose({ e.preventDefault(); } - // Since we're submitting the form here which should clear the composer - // We don't really care about saving the draft the user was typing - // We need to make sure an empty draft gets saved instead - debouncedSaveReportComment.cancel(); - const newComment = composerRef.current.prepareCommentAndResetComposer(); if (!newComment) { return;