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

Arrows not shown when using many mermaid graphs #564

Closed
twitwi opened this issue May 2, 2022 · 4 comments · Fixed by #570
Closed

Arrows not shown when using many mermaid graphs #564

twitwi opened this issue May 2, 2022 · 4 comments · Fixed by #570
Assignees

Comments

@twitwi
Copy link
Contributor

twitwi commented May 2, 2022

Describe the bug
When using several mermaid graphs (on different slides especially) the arrows are absent.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new presentation

  2. Add the following two slides using mermaid

     ---
     
     # MERMAID (same id, same shape, on the same slide would be ok)
     
     ```mermaid {theme: 'neutral', scale: 0.8}
     flowchart LR
         Start --- Stop
         A-. text .-> B
         Stop ==> A
     ```
     
     ---
     
     # MERMAID but uses arrows from previous slide...
     
     ```mermaid {theme: 'neutral', scale: 0.8}
     flowchart LR
         Start --- Stop
         A-. text .-> B
         Stop ==> A
     ```
    
  3. Visit the page navigating to the first then second slide

  4. The arrows are absent on the second slide

The actual problem is coming from having several inline SVG with the same ideas.
Draft patch available.

@twitwi twitwi self-assigned this May 2, 2022
@TheAlexLichter
Copy link
Contributor

TheAlexLichter commented May 5, 2022

@twitwi What would be the patch in this case (would be happy about a gist/repo link or even PR)? Noticed the bug as well when using multiple graphs and navigating.

Possibly related: mermaid-js/mermaid#1318

@twitwi
Copy link
Contributor Author

twitwi commented May 6, 2022

I can confirm, it is definitely the same issue.
Mermaid could solve it by generating random uniqu-ish IDs, but I guess we should not wait for it.

As for the patch, I have it ready and working but I need to do proper cleanup/refactoring before pushing it.
It is a matter of doing this https://github.com/twitwi/slidev-incubation/blob/main/incubator/components/InlineSvg.vue#L127 here

const html = computed(() => svgObj.value)

I might manage to do this week end.

@twitwi
Copy link
Contributor Author

twitwi commented May 6, 2022

Thanks to the above-linked issue, there is a simpler solution using some shadow dom.
I tested it using <shadow-root> from https://github.com/2A5F/shadow

@antfu is it a dependency that we can add or is it better to add such shadow-root functionality in VueUse?

(edit) with two more options, the choice could be among

  • wait for mermaid to "solve" the issue
  • add the 2A5F/shadow dependency
  • include a shadowRoot logic in VueUse
  • include the minimal shadowRoot logic directly in the Mermaid slidev component

I'm currently leaning towards the last option.

@TheAlexLichter
Copy link
Contributor

Well done 👍 Thanks a lot ☺️

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 a pull request may close this issue.

2 participants