Skip to content

[react] RichText builds a new dangerouslySetInnerHTML object every render, causing full DOM replacement and dropped internal-link listeners - #574

Merged
illiakovalenko merged 4 commits into
devfrom
fix/JSS-9950-richtext-dom-churn
Aug 3, 2026
Merged

[react] RichText builds a new dangerouslySetInnerHTML object every render, causing full DOM replacement and dropped internal-link listeners#574
illiakovalenko merged 4 commits into
devfrom
fix/JSS-9950-richtext-dom-churn

Conversation

@sc-naveenhedallaarachchi

Copy link
Copy Markdown
Contributor

Description / Motivation

  • Memoize RichText dangerouslySetInnerHTML (keyed on the HTML string) so React DOM does not rewrite innerHTML on unrelated parent re-renders.
  • Preserves nested DOM nodes and attached listeners (e.g. Next.js internal links).
  • Non-breaking bug fix; public API unchanged. Parallel fix for Sitecore JSS.

Testing Details

  • Unit Test Added
  • Manual Test/Other (Please elaborate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bf35885

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sitecore-content-sdk/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📦 Package Size and Test Coverage Report

Package Base Size PR Size Δ Change Base Coverage PR Coverage Δ Change
analytics-core 67.34 KB 67.34 KB ✅ 0.00 KB 97.40% 97.40% 0.00%
angular 337.93 KB 337.93 KB ✅ 0.00 KB 93.85% 93.85% 0.00%
cli 61.06 KB 61.06 KB ✅ 0.00 KB 71.36% 71.36% 0.00%
content 481.96 KB 481.96 KB ✅ 0.00 KB 92.86% 92.86% 0.00%
core 121.93 KB 121.93 KB ✅ 0.00 KB 91.09% 91.09% 0.00%
create-content-sdk-app 525.12 KB 525.12 KB ✅ 0.00 KB 96.47% 96.47% 0.00%
events 72.27 KB 72.27 KB ✅ 0.00 KB 97.97% 97.97% 0.00%
nextjs 543.01 KB 543.01 KB ✅ 0.00 KB 91.47% 91.49% +0.02%
personalize 64.01 KB 64.01 KB ✅ 0.00 KB 99.74% 99.74% 0.00%
react 235.00 KB 237.10 KB 🔺 +2.10 KB 93.89% 93.95% +0.06%
search 8.25 KB 8.25 KB ✅ 0.00 KB 98.72% 98.72% 0.00%
Total 🔺 +2.10 KB

Comment thread packages/react/src/components/RichText.tsx Outdated

@illiakovalenko illiakovalenko left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@illiakovalenko
illiakovalenko merged commit 938ddb6 into dev Aug 3, 2026
5 checks passed
@illiakovalenko
illiakovalenko deleted the fix/JSS-9950-richtext-dom-churn branch August 3, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants