Skip to content

Conversation

kriss-u
Copy link
Contributor

@kriss-u kriss-u commented Jul 11, 2025

📑 Summary

This PR fixes the wrong behavior of direction TD which should've behaved like TB.

In flowDb.ts, the method setDirection takes dir string argument representing the direction. The data received had an extra space ' ' before the direction identifier, e.g. " TD". There is a check if the direction is TD, convert it to TB with strict equality check.

Resolves #6681

📏 Design Decisions

In flowDb.ts, the method setDirection takes dir string argument representing the direction. The data received had an extra space ' ' before the direction identifier, e.g. " TD". There is a check if the direction is TD, convert it to TB with strict equality check. Thus, " TD" === "TD" is always false, hence not converted to "TB" as shown below.

if (this.direction === 'TD') {
      this.direction = 'TB';
    }

To fix this, trimming the string is the best way instead of changing the right hand side of the equality check or using another condition.

-    this.direction = dir;
+    this.direction = dir.trim();

Test with the following:

flowchart TD
    subgraph one
        a2
        a1
    end
    subgraph two
        b2
        b1
    end
    a1 --> a2
    b1 --> b2
    one --> two

📋 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:.

Copy link

changeset-bot bot commented Jul 11, 2025

🦋 Changeset detected

Latest commit: 98bf9b4

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

This PR includes changesets to release 2 packages
Name Type
mermaid Patch
@mermaid-js/examples 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

@github-actions github-actions bot added the Type: Bug / Error Something isn't working or is incorrect label Jul 11, 2025
Copy link

netlify bot commented Jul 11, 2025

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 98bf9b4
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/6870825e62b2b9000869fb64
😎 Deploy Preview https://deploy-preview-6739--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.

Copy link

pkg-pr-new bot commented Jul 11, 2025

Open in StackBlitz

@mermaid-js/examples

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

mermaid

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

@mermaid-js/layout-elk

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

@mermaid-js/mermaid-zenuml

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

@mermaid-js/parser

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

@mermaid-js/tiny

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

commit: 98bf9b4

Copy link

codecov bot commented Jul 11, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 3.85%. Comparing base (fad6676) to head (98bf9b4).
⚠️ Report is 114 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   #6739   +/-   ##
=======================================
  Coverage     3.85%   3.85%           
=======================================
  Files          455     455           
  Lines        44772   44772           
  Branches       707     707           
=======================================
  Hits          1725    1725           
  Misses       43047   43047           
Flag Coverage Δ
unit 3.85% <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.

Copy link

argos-ci bot commented Jul 11, 2025

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

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jul 11, 2025, 3:26 AM

@shubhamparikh2704 shubhamparikh2704 added this pull request to the merge queue Jul 29, 2025
Merged via the queue into mermaid-js:develop with commit 1a14e33 Jul 29, 2025
22 checks passed
Copy link

mermaid-bot bot commented Jul 29, 2025

@kriss-u, Thank you for the contribution!
You are now eligible for a year of Premium account on MermaidChart.
Sign up with your GitHub account to activate.

This was referenced Aug 19, 2025
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.

flowgraph TB vs. TD difference, when using subgraphs
2 participants