Project

General

Profile

Actions

Defect #44664

open

Mermaid diagram may be drawn into another diagram on the same page

Added by Takenori TAKAKI 2 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
UI
Target version:
-
Resolution:
Affected version:

Description

Problem

When a page contains multiple Mermaid diagrams, a diagram may be drawn into another diagram, and its own place is left empty. In the screenshot below, Diagram 3 is drawn into Diagram 2.

Cause

mermaid.run() generates the SVG id from Date.now(), so diagrams that start rendering in the same millisecond get the same id. Some Mermaid renderers look up their target element by id, so they draw into the wrong diagram. #44584 pointed out the same cause, but its fix only stopped error diagrams from being drawn, and the duplicate ids remain.

Solution

The attached patch renders each diagram with mermaid.render() and a unique id. With the patch, each diagram is drawn in its own place.


Files

mermaid-diagrams-before.png (77.6 KB) mermaid-diagrams-before.png Takenori TAKAKI, 2026-10-23 03:38
mermaid-diagrams-after.png (104 KB) mermaid-diagrams-after.png Takenori TAKAKI, 2026-10-23 03:39
fix-mermaid-duplicate-svg-ids_r25293.patch (2.95 KB) fix-mermaid-duplicate-svg-ids_r25293.patch Takenori TAKAKI, 2026-10-23 03:41

No data to display

Actions

Also available in: Atom PDF