Skip to content

Commit fa3b782

Browse files
authored
Merge pull request Expensify#63426 from nkdengineer/fix/62848
Chat - Formatting is incorrect when pasting code into the compose box
2 parents 2cf6301 + e7fcc1c commit fa3b782

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/pages/home/report/comment/TextCommentFragment.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ function TextCommentFragment({fragment, styleAsDeleted, reportActionID, styleAsM
7373
const containsEmojis = CONST.REGEX.ALL_EMOJIS.test(text ?? '');
7474
if (!shouldRenderAsText(html, text ?? '') && !(containsOnlyEmojis && styleAsDeleted)) {
7575
const editedTag = fragment?.isEdited ? `<edited ${styleAsDeleted ? 'deleted' : ''}></edited>` : '';
76-
const htmlWithDeletedTag = styleAsDeleted ? `<del>${html}</del>` : html;
76+
// We don't want to replace the space in tags with &nbsp;
77+
const escapedHtml = html.replace(/(?:(?![\n\r])\s)(?![^<]*>)/g, '&nbsp;');
78+
const htmlWithDeletedTag = styleAsDeleted ? `<del>${escapedHtml}</del>` : escapedHtml;
7779

7880
let htmlContent = htmlWithDeletedTag;
7981
if (containsOnlyEmojis) {

0 commit comments

Comments
 (0)