Skip to content

fix(flowchart): preserve raw subgraph direction value; normalize TD→TB only for dagre - #2

Merged
sjackson0109 merged 4 commits into
fix/4648-directionsfrom
copilot/add-direction-keyword-handling
May 7, 2026
Merged

sjackson0109 merged 4 commits into
fix/4648-directionsfrom
copilot/add-direction-keyword-handling

Conversation

Copilot AI commented May 7, 2026

Copy link
Copy Markdown

📑 Summary

addSubGraph() was normalizing direction TD to TB before storing it on the subgraph object. This caused subgraph.dir to return 'TB' instead of the user-authored 'TD', breaking the assertion:

packages/mermaid/src/diagrams/flowchart/parser/subgraph.spec.js
> when parsing subgraphs > should correctly parse direction TD inside a subgraph
AssertionError: expected 'TB' to be 'TD'

📏 Design Decisions

  • addSubGraph(): removed the TD→TB normalization from the storage path. subGraph.dir now holds the raw user value (e.g. 'TD').
  • getData(): normalization is applied inline when constructing the dagre layout node — dagre still receives the canonical 'TB' it requires:
dir: subGraph.dir === 'TD' ? 'TB' : subGraph.dir, // normalize TD→TB for dagre

TD is a user-facing alias; TB is dagre's internal canonical form. These two concerns now live at the correct layers.

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

Copilot AI and others added 4 commits May 7, 2026 16:36
…inheritDir

Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/6e0b59e7-9b3a-4532-bdc3-7d7893b2c0da

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
…e-consumption point

Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/ed8547c3-2e55-4088-bbec-113a7976d0aa

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/ed8547c3-2e55-4088-bbec-113a7976d0aa

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
Agent-Logs-Url: https://github.com/sjackson0109/mermaid/sessions/367892ea-7828-42ac-a114-e4e3119212ef

Co-authored-by: sjackson0109 <38080190+sjackson0109@users.noreply.github.com>
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.

2 participants