Skip to content

Subgraphs Always Default to Top-to-Down (TD), Ignoring Global Direction #6428

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

Open
nour0205 opened this issue Mar 28, 2025 · 1 comment
Open
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect

Comments

@nour0205
Copy link

nour0205 commented Mar 28, 2025

Description

In Mermaid subgraphs always default to the top-to-down (TD) layout, even if a different global direction (LR, RL, or BT) is explicitly set. This forces users to manually declare directions inside each subgraph, creating redundancy and confusion.

Steps to reproduce

Example 1: Global LR, Subgraph defaults to TD (Incorrect):

mermaid
graph LR
  subgraph ShouldInheritLR ["Should Inherit LR"]
    NodeA --> NodeB
  end

**Expected Behavior:
The subgraph should inherit the global left-to-right (LR) direction implicitly.

**Actual Behavior:
The subgraph incorrectly defaults to top-to-bottom (TD).

Example 2: Explicitly Stated Subgraph Direction (Correct but Redundant):

mermaid
graph LR
  subgraph ExplicitLR ["Explicitly LR"]
    direction LR
    NodeE --> NodeF
  end

**Actual Behavior:
Correctly renders due to explicit declaration, but redundant because global direction was already set to LR.

Screenshots

**Failing Exemple

Image

**Working Exemple

Image

Code Sample


Setup

Environment
Mermaid.js Version: v11.4.1

Browser: Microsoft Edge v132.0.2957.115

OS: Windows 11

Suggested Solutions

No response

Additional Context

No response

@nour0205 nour0205 added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Mar 28, 2025
@nour0205 nour0205 changed the title Mermaid.js Issue: Subgraphs Always Default to Top-to-Bottom (TD), Ignoring Global Direction Mermaid.js Issue: Subgraphs Always Default to Top-to-Down (TD), Ignoring Global Direction Mar 28, 2025
@nour0205 nour0205 changed the title Mermaid.js Issue: Subgraphs Always Default to Top-to-Down (TD), Ignoring Global Direction Subgraphs Always Default to Top-to-Down (TD), Ignoring Global Direction Mar 28, 2025
@nour0205
Copy link
Author

Fixed in PR: #6435

This PR fixes the bug where subgraphs defaulted to TD regardless of the global direction.
Now subgraphs inherit the graph’s direction (e.g., LR, RL, etc.) unless explicitly overridden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant