Project

General

Profile

Actions

Defect #44767

open

Mermaid diagrams in a hidden code block are rendered squashed

Defect #44767: Mermaid diagrams in a hidden code block are rendered squashed

Added by Mizuki ISHIKAWA about 22 hours ago. Updated about 22 hours ago.

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

Description

If a Mermaid code block (#44425) is hidden with display: none when Mermaid.js finishes loading, the diagram is squashed and nothing is visible once the block is shown.

Example (CommonMark Markdown): open an issue with the following description, wait until Mermaid.js has loaded, and click "Show".

{{collapse
```mermaid
graph TD;
A-->B;
```
}}

Notes in the issue history have the same problem when the issue is opened with the “Property changes” tab.


Files

Updated by Mizuki ISHIKAWA about 22 hours ago Actions #1

The attached patch fixes this by using a ResizeObserver to render a hidden block when it is shown.

Updated by Mizuki ISHIKAWA about 22 hours ago Actions #2

The ResizeObserver adds no measurable overhead. Measured with headless Chrome (median of 5 runs):

Visible diagrams Before After
--- --- ---
10 0.5 s 0.5 s
100 3.0 s 3.0 s
200 6.1 s 6.2 s

Most of the time is spent rendering with Mermaid.js. Starting to observe 10,000 hidden blocks takes about 6 ms. Diagrams in a collapse macro are now rendered when it is expanded instead of at page load. The first one appears within 100 ms.

Actions

Also available in: PDF Atom