Fix clipped mermaid node labels by pinning label line-height#149
Merged
Conversation
The page-level line-height (1.6) cascades into the HTML labels mermaid renders inside SVG foreignObject elements, but mermaid sizes node boxes assuming its own default label line-height (~1.2). Any label that wraps ends up taller than its box and the overflow is clipped. Pin line-height back to 1.2 on foreignObject label elements inside mermaid diagrams so rendered text matches the geometry mermaid measured. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
HamptonMakes
approved these changes
Jul 17, 2026
HamptonMakes
added a commit
that referenced
this pull request
Jul 20, 2026
…resh Prefer this branch's visibility model while genuinely adopting main's new features: - LinkPreviews/Slack unfurls (#154): adopted; context now speaks the visibility language — Private/Archived flagged, published unmarked, never "Draft". plan_og_description delegates to the same builder. - Mermaid comment anchors (#148/#149/#151): adopted; mermaid-settled re-highlighting wired into our no-tabs plan page, anchors-updated re-anchoring wired into our headless comment nav. Clicking a comment mark inside a diagram now opens its thread popover instead of the lightbox (showModal force-hides popovers). - Landing refresh + agent-instructions view (#140): adopted; step copy and mock badge updated to the born-published model (type badge, no status badge). - Status badge menu (#146): superseded — visibility is the only state, toggled by the header eye; status_menu_controller removed. - Attachments dropzone (#147): superseded by our add-modal dropzone; spec selectors reconciled. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
On plan pages, any mermaid flowchart node label that wraps to a second line gets cut off by the bottom of its node box. The same diagram source renders fine in mermaid-cli and other renderers.
Root cause
The page stylesheet sets
line-height: 1.6onbody. Mermaid renders node labels as HTML inside SVG<foreignObject>elements, so that page-level line-height cascades into them — but mermaid sizes node boxes assuming its own default label line-height (~1.2). Wrapped labels end up ~40% taller than the box mermaid measured for them, and the overflow is clipped. Because it's a geometry mismatch between page CSS and mermaid's layout measurement, diagram-side knobs (font size, padding, node spacing) can't fix it.Fix
Pin
line-height: 1.2on label elements insideforeignObjectwithin rendered diagrams, scoped under.markdown-rendered .mermaid-diagram, so displayed text matches the geometry mermaid laid out. This fixes every existing and future diagram without authors needing a per-diagram%%{init: ...}%%workaround.Verification
Built a replica of CoPlan's renderer — this repo's
application.css+ themermaid_controller.jsconfig (mermaid 11.16.0 from jsdelivr,securityLevel: "strict", sameinitializecall) — in headless Chrome, rendering a flowchart with wrapping labels. Before the change, the last line of every wrapped node label and edge label is clipped; after, all lines render fully. Screenshots in the comment below.Validation References
foreignObjectby default (htmlLabels): https://mermaid.js.org/config/schema-docs/config.htmlengine/app/javascript/controllers/coplan/mermaid_controller.js(renders viamermaid.render, inserts SVG into.mermaid-diagram)line-height: 1.6that leaks in:engine/app/assets/stylesheets/coplan/application.css(bodyrule)htmlLabels: falsestill clipped; adisplay: table-celloverride made some wrapped lines disappear entirely; per-diagram%%{init: {"themeCSS": ...}}%%works but requires every author to know the workaround.🤖 Generated with Claude Code