You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HOLD for payment 2023-10-02] [$500] Web - Chat - The deleted message reappears when navigating to another chat and returning #27569
changed the title [-]Web - Chat - The deleted message reappears when navigating to another chat and returning[/-][+][$500] Web - Chat - The deleted message reappears when navigating to another chat and returning[/+]on Sep 15, 2023
When deleting all text input (for example "abcdef") and clicking on send button or pressing on ENTER:
Firstly, debouncedSaveReportComment.cancel(); called to ignore the before saveReportComment action - in this case is saving the report comment as an empty string - Report.saveReportComment(reportID, ''). So after this step, the reportComment is still "abcdef" text
After that, composerRef.current.prepareCommentAndResetComposer() is called but it will check if the current comment is empty or not, if true, does not run the remaining logic.
So the report comment is still saved as "abcdef", that lead to the bug
What changes do you think we should make in order to solve the problem?
We can make sure the ``updateComment(' ')``` is called regardless the comment length is greater than 0 or not like below:
const prepareCommentAndResetComposer = useCallback(() => {
const trimmedComment = commentRef.current.trim();
const commentLength = ReportUtils.getCommentLength(trimmedComment);
updateComment('');
// Don't submit empty comments or comments that exceed the character limit
if (!commentLength || commentLength > CONST.MAX_COMMENT_LENGTH) {
return '';
}
Also in the PR detail, we need to ignore the updateComment(' ') in case exceeding the maximum character
What alternative solutions did you explore? (Optional)
Please re-state the problem that we are trying to solve in this issue.
The deleted composer message shows again if pressing enter after deleting the whole message/text.
What is the root cause of that problem?
The initial text that is shown on composer comes from the report comment draft onyx (reportDraftComment_). Every time we update the text, we save the text as a draft, but we are debouncing it so the save doesn't get called too much for each character.
// 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();
So, if we delete the whole text and then immediately press enter, the request to save the draft with an empty string is canceled, thus the onyx still holds the old value. That's why when we revisit the chat, we will see the old value shows.
What changes do you think we should make in order to solve the problem?
Cancel the debounce only if the composer is not empty.
details:
We have 2 options,
In this code, move down the debounce cancel below the if.
Activity
[-]Web - Chat - The deleted message reappears when navigating to another chat and returning[/-][+][$500] Web - Chat - The deleted message reappears when navigating to another chat and returning[/+]melvin-bot commentedon Sep 15, 2023
Triggered auto assignment to @tjferriss (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.melvin-bot commentedon Sep 15, 2023
Job added to Upwork: https://www.upwork.com/jobs/~01c0cd42dfc8371fd8
melvin-bot commentedon Sep 15, 2023
Bug0 Triage Checklist (Main S/O)
Platformsin OP are ✅)melvin-bot commentedon Sep 15, 2023
Triggered auto assignment to @JmillsExpensify (
External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.melvin-bot commentedon Sep 15, 2023
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mananjadhav (
External)DylanDylann commentedon Sep 15, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
submitFormfunction:App/src/pages/home/report/ReportActionCompose/ReportActionCompose.js
Lines 248 to 267 in d68263a
App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js
Lines 235 to 243 in d68263a
debouncedSaveReportComment.cancel();called to ignore the before saveReportComment action - in this case is saving the report comment as an empty string -Report.saveReportComment(reportID, ''). So after this step, the reportComment is still "abcdef" textcomposerRef.current.prepareCommentAndResetComposer()is called but it will check if the current comment is empty or not, if true, does not run the remaining logic.What changes do you think we should make in order to solve the problem?
updateComment(' ')in case exceeding the maximum characterWhat alternative solutions did you explore? (Optional)
Result
Screencast.from.14-09-2023.14.43.07.webm
bernhardoj commentedon Sep 16, 2023
Proposal
Please re-state the problem that we are trying to solve in this issue.
The deleted composer message shows again if pressing enter after deleting the whole message/text.
What is the root cause of that problem?
The initial text that is shown on composer comes from the report comment draft onyx (reportDraftComment_). Every time we update the text, we save the text as a draft, but we are debouncing it so the save doesn't get called too much for each character.
App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js
Lines 206 to 207 in 76c1559
When we press enter, it will call
submitFormwhich will cancel any ongoing debounce.App/src/pages/home/report/ReportActionCompose/ReportActionCompose.js
Lines 254 to 257 in 76c1559
So, if we delete the whole text and then immediately press enter, the request to save the draft with an empty string is canceled, thus the onyx still holds the old value. That's why when we revisit the chat, we will see the old value shows.
What changes do you think we should make in order to solve the problem?
Cancel the debounce only if the composer is not empty.
details:
We have 2 options,
if.App/src/pages/home/report/ReportActionCompose/ReportActionCompose.js
Lines 254 to 263 in 76c1559
submitFormtoprepareCommentAndResetComposerand call it right aboveupdateComment('')App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions.js
Lines 240 to 244 in 76c1559
32 remaining items
tjferriss commentedon Oct 2, 2023
@bernhardoj payment has been sent via Upworks.
@usmantariq96 I just sent you an offer via Upworks for the reporting bonus.
usmantariq96 commentedon Oct 3, 2023
@tjferriss I haven't received any offer yet.
tjferriss commentedon Oct 3, 2023
I'm sorry, I must have selected the wrong person. Can you please apply to the posting here: https://www.upwork.com/jobs/~01c0cd42dfc8371fd8
JmillsExpensify commentedon Oct 5, 2023
$750 payment approved for @mananjadhav based on BZ summary
tjferriss commentedon Oct 5, 2023
@usmantariq96 can you please apply to the job so we can get you paid out?
usmantariq96 commentedon Oct 6, 2023
@tjferriss applied
Thanks
tjferriss commentedon Oct 6, 2023
Offer sent
usmantariq96 commentedon Oct 7, 2023
Offer accepted
Thanks
cristipaval commentedon Oct 9, 2023
What's the payment status here? Can we close the issue?
tjferriss commentedon Oct 11, 2023
The payment has been sent to @usmantariq96 so we can close it now.