Skip to content

Revert fix(flowchart): respect per-subgraph direction keyword in Dagre layout- #7672 - #8005

Merged
pbrolin47 merged 4 commits into
mermaid-js:developfrom
pbrolin47:revert-pr-7672
Jul 29, 2026
Merged

pbrolin47 merged 4 commits into
mermaid-js:developfrom
pbrolin47:revert-pr-7672

Conversation

@pbrolin47

@pbrolin47 pbrolin47 commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

📑 Summary

This reverts #7672. From 11.16.0, users reports arrows between subgraphs are broken.

Resolves #7954
Resolves #7993 (alternate PR fixing part of #7954)

📏 Design Decisions

Describe the way your implementation works or what design decisions you made if applicable.

📋 Tasks

Make sure you

  • 📖 have read the contribution guidelines
  • 💻 have added necessary unit/e2e tests.
  • 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • 🦋 If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Summary

  • Reverted per-subgraph direction handling that broke arrows between nested subgraphs.
  • Simplified flowchart subgraph direction data by removing explicitDir tracking.
  • Restored Dagre cluster edge-copying behavior for external connections.
  • Added a regression snapshot test for nested subgraphs with outgoing links.
  • Added a patch changeset for Mermaid.
  • Updated generated LayoutData documentation references.

…-directions"

This reverts commit 98a494d, reversed
manually where later commits (collapsible subgraphs, perf logging
cleanup) had touched the same code, so those unrelated changes are
preserved.
@changeset-bot

changeset-bot Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e9bb95c

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

This PR includes changesets to release 1 package
Name Type
mermaid 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

@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Flowchart subgraph direction tracking no longer uses explicit-direction flags. Dagre cluster edge extraction is simplified, related direction tests are removed, nested outgoing-link snapshot coverage is added, and a patch changeset records the revert.

Subgraph arrow behavior

Layer / File(s) Summary
Remove explicit direction metadata
packages/mermaid/src/diagrams/flowchart/..., packages/mermaid/src/diagrams/state/..., packages/mermaid/src/rendering-util/types.ts
Subgraph and node contracts no longer store explicit direction flags while inherited direction resolution remains.
Restore subgraph edge extraction
packages/mermaid/src/diagrams/flowchart/flowDb.ts, packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js
Rendered subgraph directions are preserved directly, and Dagre copies qualifying cluster edges without endpoint rebinding or explicit-direction extraction.
Update regression coverage and release metadata
packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js, cypress/integration/rendering/flowchart/flowchart-v2.spec.js, .changeset/*, docs/config/setup/mermaid/interfaces/LayoutData.md
Direction-specific Dagre tests are removed, nested outgoing-link snapshot coverage is added, generated references are refreshed, and a patch changeset documents the revert.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: aloisklink, knsv

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The revert restores direct subgraph direction handling and tests the nested subgraph arrow case for [#7954].
Out of Scope Changes check ✅ Passed The remaining changes are support work for the revert, including tests and a changeset, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly names the revert and the Dagre per-subgraph direction change that this PR undoes.
Description check ✅ Passed The PR includes the required Summary, linked issues, and task checklist, though the Design Decisions section is left as placeholder text.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit e9bb95c
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6a69f3ec3576c20008ab3494
😎 Deploy Preview https://deploy-preview-8005--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@mermaid-js/examples

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

mermaid

npm i https://pkg.pr.new/mermaid@8005

@mermaid-js/layout-elk

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

@mermaid-js/layout-tidy-tree

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

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: e9bb95c

@codecov

codecov Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.54%. Comparing base (627fc21) to head (e9bb95c).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #8005      +/-   ##
===========================================
+ Coverage    77.46%   77.54%   +0.08%     
===========================================
  Files          564      564              
  Lines        74906    74840      -66     
  Branches     12661    12644      -17     
===========================================
+ Hits         58026    58037      +11     
+ Misses       15882    15804      -78     
- Partials       998      999       +1     
Flag Coverage Δ
e2e 70.79% <100.00%> (+0.26%) ⬆️
unit 74.80% <100.00%> (-0.03%) ⬇️

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

Files with missing lines Coverage Δ
packages/mermaid/src/diagrams/flowchart/flowDb.ts 86.16% <100.00%> (+0.35%) ⬆️
packages/mermaid/src/diagrams/state/dataFetcher.ts 96.11% <ø> (-0.02%) ⬇️
packages/mermaid/src/diagrams/state/stateDb.ts 88.76% <ø> (ø)
...g-util/layout-algorithms/dagre/mermaid-graphlib.js 92.21% <100.00%> (-0.79%) ⬇️

... and 7 files with indirect coverage changes

🚀 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

argos-ci Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

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

Build Status Details Updated (UTC)
default (Inspect) 👍 Approved by pbrolin47 1 changed Jul 29, 2026, 1:13 PM

@pbrolin47
pbrolin47 marked this pull request as ready for review July 29, 2026 07:46
@pbrolin47 pbrolin47 added the CI: full argos If set on a PR, run a full Argos upload. Remove and re-add to run another one. label Jul 29, 2026

@aloisklink aloisklink left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Remember to re-open #4648.

I've also updated the PR description to auto-close #7993 when this PR is merged, since this PR makes that one obsolete.

Comment thread cypress/integration/rendering/flowchart/flowchart-v2.spec.js
@pbrolin47
pbrolin47 added this pull request to the merge queue Jul 29, 2026
Merged via the queue into mermaid-js:develop with commit 4bc79dd Jul 29, 2026
46 checks passed
@pbrolin47
pbrolin47 deleted the revert-pr-7672 branch July 29, 2026 14:17
@github-actions github-actions Bot mentioned this pull request Aug 18, 2026
ark-65 added a commit to zhongmiao-org/mermaid-markdown-bridge that referenced this pull request Aug 21, 2026
Upstream release: https://github.com/mermaid-js/mermaid/releases/tag/mermaid%4011.17.0

Release notes:
### Minor Changes

-   [#7842](mermaid-js/mermaid#7842) [`3670b4e`](mermaid-js/mermaid@3670b4e) Thanks [@filipsajdak](https://github.com/filipsajdak)! - feat(c4): render C4 elements through the unified shape system, using the new person shape

-   [#7812](mermaid-js/mermaid#7812) [`cdfc0ea`](mermaid-js/mermaid@cdfc0ea) Thanks [@knsv-bot](https://github.com/knsv-bot)! - feat(class): route `classDiagram` to the unified (v2) renderer by default

    Set `class: { defaultRenderer: 'dagre-d3' }` in the config to restore the legacy renderer.

-   [#7785](mermaid-js/mermaid#7785) [`c45cde9`](mermaid-js/mermaid@c45cde9) Thanks [@knsv-bot](https://github.com/knsv-bot)! - feat(flowchart): add collapsible flowchart subgraphs via `subgraphId@{ view: collapsed }`

-   [#7828](mermaid-js/mermaid#7828) [`8eb3afc`](mermaid-js/mermaid@8eb3afc) Thanks [@knsv-bot](https://github.com/knsv-bot)! - feat(elk): add `elk.keepEntryNodeOnTop` config option to keep a recursive flow's entry node on top

-   [#7803](mermaid-js/mermaid#7803) [`74e44eb`](mermaid-js/mermaid@74e44eb) Thanks [@knsv-bot](https://github.com/knsv-bot)! - feat(elk): add `elk.nodePlacementAlignment` config option

-   [#7792](mermaid-js/mermaid#7792) [`ea55b31`](mermaid-js/mermaid@ea55b31) Thanks [@RodrigojndSantos](https://github.com/RodrigojndSantos)! - feat(er): add subgraph support to ER diagrams.

-   [#7970](mermaid-js/mermaid#7970) [`a2c0fb6`](mermaid-js/mermaid@a2c0fb6) Thanks [@filipsajdak](https://github.com/filipsajdak)! - feat(flowchart): add `folder`, `bucket`, `console` (terminal window) and `browser` shapes

-   [#7842](mermaid-js/mermaid#7842) [`ae3e115`](mermaid-js/mermaid@ae3e115) Thanks [@filipsajdak](https://github.com/filipsajdak)! - feat(flowchart): add `person` shape (circular head above a rounded body), usable in flowcharts via `A@{ shape: person }`

-   [#7724](mermaid-js/mermaid#7724) [`0fd7a9f`](mermaid-js/mermaid@0fd7a9f) Thanks [@xdumaine](https://github.com/xdumaine)! - feat(xyChart): add legends for named line and bar series

### Patch Changes

-   [#7847](mermaid-js/mermaid#7847) [`215fe89`](mermaid-js/mermaid@215fe89) Thanks [@filipsajdak](https://github.com/filipsajdak)! - fix(c4): named attributes such as `$tags`, `$link` and `$sprite` are no longer clobbered to undefined when they arrive in an earlier positional slot of Person/System/Container/Component/Boundary/Rel statements.

-   [#7871](mermaid-js/mermaid#7871) [`8d874c4`](mermaid-js/mermaid@8d874c4) Thanks [@knsv-bot](https://github.com/knsv-bot)! - fix(flowchart): stop dagre layout from spamming `warn`-level logs on every node/edge/cluster

-   [#8071](mermaid-js/mermaid#8071) [`b3d1f63`](mermaid-js/mermaid@b3d1f63) Thanks [@pbrolin47](https://github.com/pbrolin47)! - fix(block): sibling blocks overlapping in block diagrams when one has a label wider than 200px

-   [#7870](mermaid-js/mermaid#7870) [`71b8843`](mermaid-js/mermaid@71b8843) Thanks [@knsv-bot](https://github.com/knsv-bot)! - fix: a `RangeError: Invalid array length` crash when rendering certain edges.

-   [#7924](mermaid-js/mermaid#7924) [`9cbef5d`](mermaid-js/mermaid@9cbef5d) Thanks [@nightt5879](https://github.com/nightt5879)! - fix(treeView): icons disappearing after strict security sanitization.

-   [#7850](mermaid-js/mermaid#7850) [`a34cbf0`](mermaid-js/mermaid@a34cbf0) Thanks [@aloisklink](https://github.com/aloisklink)! - fix(block): allow classdefs to update text color

-   [#7937](mermaid-js/mermaid#7937) [`f9cbe1e`](mermaid-js/mermaid@f9cbe1e) Thanks [@filipsajdak](https://github.com/filipsajdak)! - fix(dagre): let a diagram's own nodeSpacing/rankSpacing take effect in the unified dagre layout

-   [#8005](mermaid-js/mermaid#8005) [`90eeece`](mermaid-js/mermaid@90eeece) Thanks [@pbrolin47](https://github.com/pbrolin47)! - fix(flowchart): reverts the behavior change from #7672 (fix/4648-directions), since arrows between subgraphs are broken

-   [#7951](mermaid-js/mermaid#7951) [`afa2f80`](mermaid-js/mermaid@afa2f80) Thanks [@aloisklink](https://github.com/aloisklink)! - perf: use `fastdom` to batch DOM measurements (up to 25% speedup)

-   Updated dependencies \[[`e848423`](mermaid-js/mermaid@e848423)]:
    -   @mermaid-js/parser@1.2.1

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: give me a 98K <240642031+inhuman-0@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI: full argos If set on a PR, run a full Argos upload. Remove and re-add to run another one. Sponsored by MermaidChart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Arrows between subgraphs are broken since 11.16.0 (direction statement in subgraph)

2 participants