Skip to content

Commit 9e54be5

Browse files
marcochavezfclaude
andcommitted
Fix suggested followup button: preserve HTML formatting and fix response ordering
Bug A: Use dom-serializer render() instead of DomUtils.textContent() to preserve HTML formatting in followup responses. Add isHTML parameter to buildOptimisticAddCommentReportAction to skip getParsedComment() when input is already HTML. Bug B: Add createdOffset: 1 to the Concierge response so its timestamp is 1ms after the question, ensuring correct ordering. The visual typing delay is handled separately by displayAfter in addOptimisticConciergeActionWithDelay. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a910e49 commit 9e54be5

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/libs/ReportActionFollowupUtils/index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import render from 'dom-serializer';
12
import {DomUtils, parseDocument} from 'htmlparser2';
23
import {getReportActionMessage, isActionOfType} from '@libs/ReportActionsUtils';
34
import CONST from '@src/CONST';
@@ -53,7 +54,7 @@ function parseFollowupsFromHtml(html: string): Followup[] | null {
5354
const followupTextElement = DomUtils.getElementsByTagName('followup-text', followupEl, true).at(0);
5455
const followupResponseElement = DomUtils.getElementsByTagName('followup-response', followupEl, true).at(0);
5556
const text = followupTextElement ? DomUtils.textContent(followupTextElement) : '';
56-
const response = followupResponseElement ? DomUtils.textContent(followupResponseElement) : undefined;
57+
const response = followupResponseElement ? render(followupResponseElement.children) : undefined;
5758
return {text, response};
5859
});
5960
}

‎src/libs/ReportUtils.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ type BuildOptimisticAddCommentReportActionParams = {
368368
reportID?: string;
369369
reportActionID?: string;
370370
attachmentID?: string;
371+
isHTML?: boolean;
371372
};
372373

373374
type OptimisticReportAction = {
@@ -6399,8 +6400,9 @@ function buildOptimisticAddCommentReportAction({
63996400
reportID,
64006401
reportActionID = rand64(),
64016402
attachmentID,
6403+
isHTML = false,
64026404
}: BuildOptimisticAddCommentReportActionParams): OptimisticReportAction {
6403-
const commentText = getParsedComment(text ?? '', {reportID});
6405+
const commentText = isHTML ? (text ?? '') : getParsedComment(text ?? '', {reportID});
64046406
const attachmentHtml = getUploadingAttachmentHtml(file, attachmentID);
64056407

64066408
const htmlForNewComment = `${commentText}${commentText && attachmentHtml ? '<br /><br />' : ''}${attachmentHtml}`;

‎src/libs/actions/Report/SuggestedFollowup.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ function resolveSuggestedFollowup(
8080
const optimisticConciergeAction = buildOptimisticAddCommentReportAction({
8181
text: selectedFollowup.response,
8282
actorAccountID: CONST.ACCOUNT_ID.CONCIERGE,
83+
createdOffset: 1,
8384
reportActionID: optimisticConciergeReportActionID,
8485
reportID,
86+
isHTML: true,
8587
});
8688

8789
addOptimisticConciergeActionWithDelay(reportID, optimisticConciergeAction);

0 commit comments

Comments
 (0)