Conversation
…rors on article page #779
WalkthroughA Changesets metadata entry was added to document a patch version bump for the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related issues
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/ui/src/components/Content/RichText/RichText.tsx (1)
134-141: Pragmatic fix; note the semantic tradeoff.Switching the paragraph override to
divcorrectly avoids the<p>-cannot-contain-block hydration error (e.g., when Markdown paragraphs wrap images/figures/divs via overrides). SincetypographyVariantsclasses are element-agnostic, visual styling is preserved.Tradeoff worth acknowledging: all Markdown paragraphs now render as non-semantic
divs, which is a minor accessibility/SEO regression vs. valid<p>output. If you want to preserve<p>for the common case, a more targeted alternative is to inspectchildrenand only fall back todivwhen a block-level child is detected; otherwise, this fix is acceptable given markdown-to-jsx's limitations.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/ui/src/components/Content/RichText/RichText.tsx` around lines 134 - 141, The override for markdown paragraphs currently renders as <p> which causes hydration errors when a paragraph contains block children; modify the paragraph override in the RichText mapping so the p key uses TypographyComp with tag set to 'div' (preserving visual styles via baseFontSize and className) instead of 'p'; if you want to preserve semantics later, add a follow-up enhancement: inspect children in the paragraph renderer and only switch to 'div' when a block-level child is detected, otherwise render as 'p'.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/ui/src/components/Content/RichText/RichText.tsx`:
- Around line 134-141: The override for markdown paragraphs currently renders as
<p> which causes hydration errors when a paragraph contains block children;
modify the paragraph override in the RichText mapping so the p key uses
TypographyComp with tag set to 'div' (preserving visual styles via baseFontSize
and className) instead of 'p'; if you want to preserve semantics later, add a
follow-up enhancement: inspect children in the paragraph renderer and only
switch to 'div' when a block-level child is detected, otherwise render as 'p'.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e2381025-c18f-4585-a15c-eb6432453c20
📒 Files selected for processing (2)
.changeset/sad-lies-kick.mdpackages/ui/src/components/Content/RichText/RichText.tsx
Coverage Report for packages/configs/vitest-config
File CoverageNo changed files found. |
Fixes #779
Problem
The RichText component's
poverride renders paragraphs as<p>elements via TypographyComp. When content contains block-level descendants (e.g.<div>from ImgComp or nested<p>from HTML), this produces invalid HTML nesting and triggers Next.js hydration errors:In HTML, <p> cannot be a descendant of <p>Hydration failed because... Invalid HTML tag nestingSolution
Changed the
poverride in RichText to usetag: 'div'instead of the default'p'. This allows block-level descendants while preserving visual styling (Typography applies styles via variant, not tag).Changes
packages/ui/src/components/RichText/RichText.tsx— addedtag: 'div'to paragraph override propsChangeset
Included as
@o2s/uipatch.Summary by CodeRabbit
Bug Fixes