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

Typing a semicolon creates a new state node instead of being included in the transition text #5410

Open
anlai46 opened this issue Mar 24, 2024 · 1 comment
Labels
Graph: State Status: Pending Is not to be executed as it currently is Type: Bug / Error Something isn't working or is incorrect

Comments

@anlai46
Copy link
Contributor

anlai46 commented Mar 24, 2024

Description

When using the live editor to create a state diagram in Mermaid.js, I encountered an issue where typing a semicolon ";" in the text description of a transition results in the semicolon and everything after it being interpreted as the name of a new state node. This could lead users to accidentally create new state nodes and mess up the original layout of the state diagram.

Steps to reproduce

  1. Open Mermaid live editor.
  2. Create a simple state diagram with transition arrow between two state nodes
  3. Type a semicolon in the text description for the transition.
  4. See that a new node is created and named with the semicolon and everything after

Screenshots

Expected Behavior:
image

Actual Behavior:
image

Code Sample

---
title: lastTtoA
---
stateDiagram 
    direction LR

    classDef badBadEvent 
    fill:#f00,color:white,font-weight:bold,stroke-width:2px,stroke:yellow

    q0 --> q0
    q0 --> q1
    q1 --> q1
    q1 --> qHalt:::badBadEvent: T;A,S

Setup

  • Mermaid version: Latest
  • Browser and Version: Chrome

Suggested Solutions

  • Improve parser so that it recognizes when semicolons are part of the transition text instead of node names
  • Maybe we can implement the backslash character "" before the semicolon to show that it's text instead of a node marker

Additional Context

No response

@anlai46 anlai46 added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Mar 24, 2024
@anlai46 anlai46 changed the title Typing a semicolon in the live editor creates a new state node instead of being included in the transition text Typing a semicolon creates a new state node instead of being included in the transition text Mar 25, 2024
@nirname
Copy link
Contributor

nirname commented Jun 19, 2024

That is because ; is considered to be the end of the line along with \n but ; is optional, so I am not sure if it is possible to introduce this without breaking changes.

Not sure if this eol is used at all, but you can see that ; was excluded from some expressions deliberately, check this

Perhaps we should find some workaround

@nirname nirname added Type: Enhancement New feature or request Status: Pending Is not to be executed as it currently is Graph: State and removed Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Graph: State Status: Pending Is not to be executed as it currently is Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants