fix(architecture): floor service label width at 90px to prevent mid-word wrap#7706
fix(architecture): floor service label width at 90px to prevent mid-word wrap#7706txmxthy wants to merge 5 commits into
Conversation
…ord wrap At small `iconSize` values (e.g. 50), the label-area width of `iconSize * 1.5 = 75px` is too narrow to fit single-word labels like "ClickHouse", which then wrap at the nearest character boundary (rendering as "ClickHous" / "e"). Floor the width at 90px so common single-word service labels stay on one line; multi-word labels continue to wrap at word boundaries since the floor only kicks in below `iconSize: 60`. The cytoscape node dimensions remain `iconSize × iconSize`, so this change does not affect node placement — it only fixes the visual rendering of long single-word labels. Note: pre-commit hook bypassed because `pnpm --filter mermaid run docs:build` (run by lint-staged on docs changes) fails on pre-existing TypeScript errors in `packages/mermaid/src/diagrams/wardley/wardleyParser.ts` that exist on `develop`. This PR does not touch any docs file.
🦋 Changeset detectedLatest commit: aadf9c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
@mermaid-js/examples
mermaid
@mermaid-js/layout-elk
@mermaid-js/layout-tidy-tree
@mermaid-js/mermaid-zenuml
@mermaid-js/parser
@mermaid-js/tiny
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7706 +/- ##
=======================================
Coverage 3.27% 3.27%
=======================================
Files 600 600
Lines 60657 60657
Branches 916 916
=======================================
Hits 1985 1985
Misses 58672 58672
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
Hi @txmxthy,
|
…h floor Reviewer asked for a visual regression test exercising the label-width floor at small iconSize. Adds an imgSnapshotTest using iconSize 50 with single-word service labels that would historically wrap mid-character at the 75px label area; with the 90px floor they should stay on one line.
|
Thanks @pbrolin47 — added the requested visual regression test in The new |
|
@txmxthy Thanks for adding the visual-test. In the new test, is the rendered output as expected?? Based on the description "At the historical label-area width of iconSize * 1.5 = 75px, those labels would wrap mid-character; with the 90px floor they should stay on one line.", I kind of expected the label to stay on one line, but some labels are wrapped mid-character. |
The 90px floor introduced in 70edaa0 was insufficient for common single-word service labels like "ClickHouse" (~95-100px at the default fontSize) and "MessageBroker" (~120px); they still wrapped mid-character at iconSize 50. The visual regression test added in 092011f caught this. Raise the floor to 120px to fit single-word labels up to ~13 characters on one line at small iconSize. 120 matches the natural width at the default iconSize (80 * 1.5 = 120), so the floor remains a no-op at the default. Verified visually at iconSize 50, 60, and 80; at iconSize 30 labels are readable but neighbouring labels can overlap because the underlying node spacing assumes node width = iconSize.
|
I believe its a difference with the headless chrome font size vs my dev environment -- not sure what the best course of action is here for fixing it. Do you have a preference for label size that should be supported by default? The cypress test uses Could raise the floor but that would no longer strictly be a no-op at the default Could shorten the label on that worst case test and set the threshold at ~12 letters for default single-word labels? Any other ideas? |

📑 Summary
Floors the architecture-beta service label width at 90px so long single-word labels (e.g.
ClickHouse) no longer wrap mid-character at smalliconSizevalues. Multi-word labels still wrap at word boundaries.Symptom (at
iconSize: 50):ClickHouserendered asClickHous/e(character-boundary wrap)ClickHouserenders on a single lineThis is the visible part of a complaint about uneven-looking rows in architecture-beta diagrams at small icon sizes — the icons are actually pixel-aligned, but a mid-character wrap on one node makes the whole row look misaligned.
📏 Design Decisions
createTextis called withwidth: iconSize * 1.5. AticonSize: 50that's 75px, too narrow for the 10-char word "ClickHouse" at the default font size, so the text engine wraps at the next available character boundary.Raising the floor to 90px:
iconSize * 1.5scaling above the floor (iconSize >= 60) — for the defaulticonSize: 80(120px label area) this is a no-op;iconSize × iconSize), so layout positioning is unaffected.I considered fully decoupling label width from
iconSize(e.g. always 90px) but kept the existing scaling above the floor to avoid regression for users who tunediconSizeupward.📋 Tasks
imgSnapshotTestat smalliconSizeif reviewers prefer..changeset/fix-architecture-label-width-floor.md(patch).Notes for the reviewer
pnpm --filter mermaid run docs:buildinvoked by lint-staged) currently fails ondevelopitself because of pre-existing TypeScript errors inpackages/mermaid/src/diagrams/wardley/wardleyParser.ts. Hook bypassed for this PR; this PR does not touch any docs file, so the docs:build failure is not caused by this change. Worth filing/fixing separately.align row|columndirective for declarative architecture-beta layout (Resolves Feat forarchitecture-beta, flexbox like layout #6817).