Skip to content

fix(flowchart): make subgraphs inherit global graph direction by default #6435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

nour0205
Copy link

📑 Summary

Fixes an issue where subgraphs in flowcharts always default to TD (top-down) layout, ignoring the global graph direction (LR, RL, BT).

Resolves #6428

📏 Design Decisions

Modified flowDb.ts to assign dir = getDirection() when the subgraph's direction is not explicitly set.

**before
image

**after

image

📋 Tasks

Make sure you

  • [x ] 📖 have read the contribution guidelines
  • [ x] 💻 have added necessary unit/e2e tests.
  • [x ] 📓 have added documentation. Make sure MERMAID_RELEASE_VERSION is used for all new features.
  • [ x] 🦋 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:.

Copy link

changeset-bot bot commented Mar 28, 2025

⚠️ No Changeset found

Latest commit: 30567cb

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

Copy link

netlify bot commented Mar 28, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 30567cb
🔍 Latest deploy log https://app.netlify.com/sites/mermaid-js/deploys/67e72f363ad50a0008f98ce7
😎 Deploy Preview https://deploy-preview-6435--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 site configuration.

Copy link

pkg-pr-new bot commented Mar 28, 2025

Open in Stackblitz

npm i https://pkg.pr.new/mermaid-js/mermaid@6435
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/layout-elk@6435
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/mermaid-zenuml@6435
npm i https://pkg.pr.new/mermaid-js/mermaid/@mermaid-js/parser@6435

commit: 30567cb

Copy link

argos-ci bot commented Mar 28, 2025

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

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 18 changed Mar 28, 2025, 11:31 PM

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 3.86%. Comparing base (936d107) to head (30567cb).
Report is 82 commits behind head on develop.

Files with missing lines Patch % Lines
packages/mermaid/src/diagrams/flowchart/flowDb.ts 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #6435   +/-   ##
=======================================
  Coverage     3.86%   3.86%           
=======================================
  Files          412     412           
  Lines        43189   43189           
  Branches       664     664           
=======================================
  Hits          1670    1670           
  Misses       41519   41519           
Flag Coverage Δ
unit 3.86% <0.00%> (ø)

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 0.00% <0.00%> (ø)
🚀 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.

@nour0205
Copy link
Author

The Argos visual diffs are expected due to the fix for subgraph direction inheritance. Subgraphs now inherit the global graph direction instead of defaulting to TD, which changes their layout. Please accept these changes in Argos or mark them as expected.

@nour0205
Copy link
Author

@ashishjain0512 can you please review the argos changes ?

@ashishjain0512
Copy link
Collaborator

@nour0205 I looked at the PR and I think this is a welcome change, and agree that there can we some scenarios where the users would want same direction throughout the flowchart.

However, it was a conscious decision to have it implemented in the current state, where each nested layer of sub-graph alternates the directions to utilize space and let the diagram grow both vertically and horizontally.

Also, we believe any new changes should have a minimum impact on existing diagrams, and this change could impact all flowcharts with sub-graph.

I propose we add a flowchart config option inheritDir which when enabled will inherit and apply same direction across.

Once this is driven via configuration, and you add some rendering and spec test around it, we will be happy to merge.

If you have questions, you can reach out here.

CC: @knsv

@knsv
Copy link
Collaborator

knsv commented Apr 14, 2025

Closing this in favor of your new PR #6470

@knsv knsv closed this Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subgraphs Always Default to Top-to-Down (TD), Ignoring Global Direction
3 participants