Skip to content
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

Direction TD Inside subgraph Causes Parsing Error #6338

Open
nour0205 opened this issue Mar 1, 2025 · 1 comment
Open

Direction TD Inside subgraph Causes Parsing Error #6338

nour0205 opened this issue Mar 1, 2025 · 1 comment
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 1, 2025

Description

In Mermaid.js, setting direction TD inside a subgraph results in a parsing error, while other directions (LR, RL, BT) function correctly.

This is inconsistent because:

  • TD is a valid global direction.
  • direction is generally allowed inside subgraph for other layouts.

Steps to reproduce

Case 1: direction TD Fails Inside Subgraph


graph LR
  subgraph A ["Subgraph A - Top to Bottom"]
    direction TD
    X["Node X"] --> Y["Node Y"]
  end

Expected Behavior:
The subgraph should follow TD direction, positioning nodes from top to bottom.

Actual Behavior:
Mermaid.js throws a parsing error.


Case 2: TD Works Globally


graph TD
  subgraph A ["Subgraph A - Top to Bottom"]
    X["Node X"]
    Y["Node Y"]
    X --> Y
  end

Expected and Actual Behavior:
The subgraph correctly follows TD layout, confirming that TD is valid globally.


Case 3: Other Directions Work Inside Subgraphs


graph LR
  subgraph A ["Right to Left"]
    direction RL
    X["Node X"] --> Y["Node Y"]
  end

  subgraph B ["Bottom to Top"]
    direction BT
    M["Node M"] --> N["Node N"]
  end

Expected and Actual Behavior:
Both subgraphs respect their assigned directions (RL and BT).
This confirms that direction is supported inside subgraphs—except for TD.

Screenshots

Image

Image

Code Sample


Setup

  • Mermaid.js Version: v11.4.1
  • Browser and Version:Microsoft Edge v132.0.2957.115
  • OS: Windows 11

Suggested Solutions

No response

Additional Context

This issue prevents using TD inside subgraphs, making it inconsistent with how direction works for other layouts.

Since TD works globally and TB works inside subgraphs, this behavior is likely a parser inconsistency.

@nour0205 nour0205 added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Mar 1, 2025
@BambioGaming
Copy link

This issue might be caused by a parsing inconsistency in Mermaid.js when handling direction TD inside a subgraph. While other directions like LR, RL, and BT seem to work, TD might not be properly recognized within subgraphs due to how Mermaid processes directional changes.

Will try to investigate this issue further.

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

No branches or pull requests

2 participants