Skip to content

Commit

Permalink
Merge pull request #27682 from bernhardoj/fix/27569-composer-draft-is…
Browse files Browse the repository at this point in the history
…-not-saved

Fix deleted composer message reappears when revisiting the chat
  • Loading branch information
cristipaval authored Sep 20, 2023
2 parents 09fe428 + 7f72de4 commit 94c07ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,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) {
Expand Down
10 changes: 0 additions & 10 deletions src/pages/home/report/ReportActionCompose/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 94c07ea

Please sign in to comment.