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

Sequence diagram arrows and numbers disappear #270

Open
hak33m16 opened this issue Aug 9, 2024 · 4 comments
Open

Sequence diagram arrows and numbers disappear #270

hak33m16 opened this issue Aug 9, 2024 · 4 comments
Labels

Comments

@hak33m16
Copy link

hak33m16 commented Aug 9, 2024

Extension version: v1.23.1
VS code version: 1.92.0

If you put a sequence diagram inside of a details tag, and then create another sequence diagram on that same page, all subsequence sequence diagrams will appear to be missing their arrows and numbers due to a coloring issue

# test

## First

<details>

``mermaid # removed 3rd backtick for sample
sequenceDiagram
    autonumber
    participant User
    participant Client
    User-->>Client: Talks to client
`` # removed 3rd backtick for sample

</details>

## Second

``mermaid # removed 3rd backtick for sample
sequenceDiagram
    autonumber
    participant User
    participant Client
    User-->>Client: Talks to client
`` # removed 3rd backtick for sample

Removing the details section fixes it

Two with first inside of details Screenshot 2024-08-09 at 2 52 45 PM
Highlight seemingly empty section Screenshot 2024-08-09 at 2 52 52 PM
No details section Screenshot 2024-08-09 at 2 56 49 PM
@Bunker-D
Copy link
Contributor

Bunker-D commented Aug 22, 2024

It looks like issue I fixed for Obsidian! Maybe somebody can take that to fix the issue here too.

Problem

Assuming it is the same issue, it stems from the fact that arrows and other markers use an id rather than a class to be formatter. This was a known issue with Mermaid: #1318, #1871, #3267.

This led to duplicate ids for the markers. And when a marker, like an arrow, is added to an edge, it is referred to using url(#<id>)… which has the effect use not necessary the maker from this graph, but the first one found in the document, i.e., potentially one that is hidden.

Solutions

Solution 0: Mermaid update?

It seems that this issue with Mermaid is supposed to be resolved.

That being said, it is supposed to be resolved since Mermaid v10.5.0, and the package.json of this extension refers to Mermaid v10.9.0. 🤷‍♀️

Solution 1: Making the ids identical

One solution is to modify the DOM elements of the SVG produced by Mermaid, and replace every marker id with a unique id.

See the implementation I proposed for Obsidian.

Solution 2: Injecting “visible” markers early in the HTML

The other solution is more of a hack, and consists into creating markers with the same ids that would be the first elements with this id in the HTML, and that would be hidden from the user in practice but would not have the visibility: hidden trait.

I implemented that as a hack to fix the issue for Obsidian (before Solution 1 was implemented). More explanations here.

@Bunker-D
Copy link
Contributor

Update:

Actually, the issue has been solved in Mermaid only for some types of graphs (Class diagrams (classDiagram), Flowcharts (flowchart), State diagrams (stateDiagram-v2)), but not the others (C4 Context diagrams (C4Context), Entity Relationship diagrams (erDiagram), Requirement diagram (requirementDiagram), Sequence diagrams (sequenceDiagram), User journeys (journey)).

I'm currently trying to implement and push a fix for the remaining graph types.

@mjbvz
Copy link
Owner

mjbvz commented Sep 16, 2024

Easily copiable markdown showing the issue:

## First

<details>

```mermaid 
sequenceDiagram
    autonumber
    participant User
    participant Client
    User-->>Client: Talks to client
```

</details>

## Second

```mermaid
sequenceDiagram
    autonumber
    participant User
    participant Client
    User-->>Client: Talks to client
```

@Bunker-D
Copy link
Contributor

Bunker-D commented Sep 16, 2024

@mjbvz I see you labeled the issue as a bug on your side. But it really is a bug with Mermaid itself, that has been partially corrected. I proposed a resolution for the issue through pull request #5756, but it was blocked due to a file I fail to remove from the PR (see the conversation there). If you can help on this side, this would probably be easier and more relevant than implementing a workaround in your own extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants