Skip to content

fix(mermaid): prevent clipped multiline labels - #369

Merged
youyongsong merged 1 commit into
mainfrom
fix/mermaid-label-clipping
Oct 30, 2026
Merged

youyongsong merged 1 commit into
mainfrom
fix/mermaid-label-clipping

Conversation

@youyongsong

Copy link
Copy Markdown
Collaborator

Why

Mermaid measures labels under document.body when no rendering container is supplied. Doom then inserts the SVG into the Rspress documentation page, whose paragraph styles change the labels' line height. The foreignObject dimensions stay unchanged, clipping text such as an example IP address, switch, and auth-response.set-cookie.

For example, a three-line label is measured at 72px with Mermaid 11 or 63px with Mermaid 12, but becomes 84px tall inside the documentation page.

What changed

Pass the display container to mermaid.render so label measurement and display use the same page styles. Add a patch changeset.

Browser verification covers all eight Mermaid diagrams from acp-docs release-4.4 (a1ef0023), in light and dark themes, with both Mermaid 11.15.0 and #368's Mermaid 12.2.0 (1a35cc7 applied locally).

Version Views Labels checked Clipped before Clipped after
main / Mermaid 11 16 158 6 0
#368 / Mermaid 12 16 158 64 0

The check was calibrated against the known clipped diagrams and the complete Mermaid 11 cookie diagram. All 32 views render successfully, with no page exceptions, Mermaid parse errors, or external requests. The previously clipped final lines now fit inside their label boxes.

Local validation on Node 24: build, lint, 669 tests, 100% type coverage, and Doom's documentation site build pass. Both versions' eight-diagram sites also build successfully.

@changeset-bot

changeset-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9466fa6

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

This PR includes changesets to release 1 package
Name Type
@alauda/doom 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

@pkg-pr-new

pkg-pr-new Bot commented Oct 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

yarn add https://pkg.pr.new/@alauda/doom@369.tgz
yarn add https://pkg.pr.new/@alauda/doom-export@369.tgz

commit: 9466fa6

@codecov

codecov Bot commented Oct 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.94%. Comparing base (feecfff) to head (9466fa6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #369   +/-   ##
=======================================
  Coverage   66.94%   66.94%           
=======================================
  Files         100      100           
  Lines        3903     3903           
  Branches     1152     1152           
=======================================
  Hits         2613     2613           
  Misses       1026     1026           
  Partials      264      264           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@youyongsong
youyongsong merged commit 3009df4 into main Oct 30, 2026
16 checks passed
@youyongsong
youyongsong deleted the fix/mermaid-label-clipping branch October 30, 2026 06:20
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.

1 participant