Skip to content

Conversation

@kdy10091009
Copy link

@kdy10091009 kdy10091009 commented Nov 23, 2025

📑 Summary

Fixes #7175 — group boxes in architecture diagrams could overlap or not expand correctly when group names are long or children have wide rendered sizes. This patch changes how group bounding boxes are computed so the group rectangle is derived from children's rendered widths/heights (when available) plus padding.

Resolves #7175

📏 Design Decisions

  • Calculate group bounding box from rendered child element sizes when available:
    • For each child, prefer element.node().getBBox() (via db.getElementById(id)) and fall back to cytoscape child data width/height.
    • Aggregate min/max left/top/right across children and then apply configured padding.
  • If a group has no children, fall back to cy.boundingBox() as before.
  • Preserve existing offsets used for icons/labels and keep label/icon placement behavior.
  • Keep changes minimal and focused to drawGroups in packages/mermaid/src/diagrams/architecture/svgDraw.ts.

📋 Tasks

  • 📖 Read the contribution guidelines.
  • 💻 Added unit tests to cover the drawGroups behavior (packages/mermaid/src/diagrams/architecture/svgDraw.spec.ts).
  • 💻 Added an E2E image snapshot for the group-sizing rendering (cypress/integration/rendering/architecture-group-sizing.spec.js).
  • 📓 If maintainers want documentation updates, I can add or update docs (not required for this bug fix).
  • 🦋 No changeset added — please advise if you want a changeset for release notes; I can add one (pnpm changeset).

Files changed (high level)

  • Modified: packages/mermaid/src/diagrams/architecture/svgDraw.ts — compute group bbox from children + padding
  • Added: packages/mermaid/src/diagrams/architecture/svgDraw.spec.ts — TypeScript unit tests (mocking createText to avoid heavy DOM emulation)
  • Added: cypress/integration/rendering/architecture-group-sizing.spec.js — E2E image snapshot test

Local verification

  • Ran full unit test suite locally:
    • pnpm test — All unit tests passed locally (Test Files 104 passed | 1 skipped; Tests 3684 passed | 12 skipped | 2 todo).
  • Note: I did not run the full Cypress suite locally (it is slow and depends on dev server availability). The E2E snapshot test is included in this PR and will run in CI.

CI notes & follow-ups

  • codecov: If codecov reports missing coverage, I can add more focused unit tests to hit additional branches in drawGroups.
  • Argos / visual diffs: The E2E image snapshot may produce visual diffs in Argos; if intended, the maintainers should approve updated snapshots in the visual regression tool.

If you'd like, I can:

  • Add a changeset and update this PR accordingly.
  • Run a targeted Cypress spec locally (I can start a dev server and run only the new spec).
  • Add more unit tests to cover further edge cases.

Thanks! Please let me know which follow-up you'd prefer.

@changeset-bot
Copy link

changeset-bot bot commented Nov 23, 2025

⚠️ No Changeset found

Latest commit: 5c9e8ec

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Nov 23, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 5c9e8ec
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6923a8adcc40ae00085a4420
😎 Deploy Preview https://deploy-preview-7190--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Nov 23, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 23, 2025

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/examples@7190

mermaid

npm i https://pkg.pr.new/mermaid-js/mermaid@7190

@mermaid-js/layout-elk

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@7190

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-tidy-tree@7190

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@7190

@mermaid-js/parser

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@7190

@mermaid-js/tiny

npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/tiny@7190

commit: 5c9e8ec

@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

❌ Patch coverage is 0% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 3.54%. Comparing base (b1fe4ff) to head (5c9e8ec).

Files with missing lines Patch % Lines
...kages/mermaid/src/diagrams/architecture/svgDraw.ts 0.00% 57 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           develop   #7190      +/-   ##
==========================================
- Coverage     3.55%   3.54%   -0.01%     
==========================================
  Files          473     473              
  Lines        47500   47556      +56     
  Branches       731     731              
==========================================
  Hits          1687    1687              
- Misses       45813   45869      +56     
Flag Coverage Δ
unit 3.54% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...kages/mermaid/src/diagrams/architecture/svgDraw.ts 0.28% <0.00%> (-0.06%) ⬇️
🚀 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.

@argos-ci
Copy link

argos-ci bot commented Nov 23, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 1 changed, 1 added Nov 24, 2025, 12:46 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug / Error Something isn't working or is incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Architecture Diagram - Groups With Long Names Overlap

1 participant