Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-architecture-label-width-floor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'mermaid': patch
---

fix: floor architecture-beta service label width at 90px so long single-word labels (e.g. `ClickHouse`) no longer wrap mid-character at small `iconSize` values
18 changes: 18 additions & 0 deletions cypress/integration/rendering/architecture/architecture.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,24 @@ describe('architecture diagram', () => {
{ architecture: { randomize: true }, screenshot: false }
);
});
it('should keep long single-word service labels on one line at small iconSize', () => {
// Regression test for the label-width floor. At `iconSize: 50`, the
// historical width (`iconSize * 1.5 = 75px`) was too narrow to fit common
// single-word labels like "ClickHouse", causing mid-character wraps.
// The fix floors the label-area width at 90px so
// these labels stay on one line. Multi-word labels still wrap on word
// boundaries.
imgSnapshotTest(
`architecture-beta
service ch(database)[ClickHouse]
service pg(database)[Postgres]
service mb(server)[MessageBroker]
ch:R --> L:pg
pg:R --> L:mb
`,
{ architecture: { iconSize: 50 } }
);
});
});

describe('architecture - fcose layout knobs', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/mermaid/src/diagrams/architecture/svgDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,11 @@ export const drawServices = async function (
service.title,
{
useHtmlLabels: false,
width: iconSize * 1.5,
// Floor at 120px so long single-word labels (e.g. "ClickHouse", "MessageBroker")
// don't wrap mid-character at small iconSize. 120 matches the natural width at the
// default iconSize (80 * 1.5 = 120) β€” so the floor is a no-op at the default and
// only kicks in for iconSize values below 80.
width: Math.max(iconSize * 1.5, 120),
classes: 'architecture-service-label',
},
config
Expand Down
Loading