Skip to content

fix multiple renders of the same mermaid diagram#59

Merged
haydenbleasel merged 3 commits intomainfrom
51-multiple-mermaid-code-block-will-show-only-last-image
Aug 28, 2025
Merged

fix multiple renders of the same mermaid diagram#59
haydenbleasel merged 3 commits intomainfrom
51-multiple-mermaid-code-block-will-show-only-last-image

Conversation

@haydenbleasel
Copy link
Contributor

@haydenbleasel haydenbleasel commented Aug 28, 2025

This pull request addresses a bug in the Mermaid diagram rendering logic that caused multiple renders of the same diagram. The changes ensure that each Mermaid diagram instance is uniquely identified, preventing duplicate renders and improving user experience. Additionally, the demo text for Mermaid diagrams was updated for clarity.

Diagram rendering bug fix:

  • Changed the logic for generating unique IDs for Mermaid diagrams in packages/streamdown/lib/mermaid.tsx to use a combination of chart content hash, timestamp, and a random string, ensuring uniqueness and preventing multiple renders of the same diagram.
  • Added a changeset file documenting the patch fix for multiple renders of the same Mermaid diagram. (.changeset/social-bugs-doubt.md)

Documentation update:

  • Updated the demo text in apps/website/app/components/mermaid.tsx to clarify that users should click the copy icon next to any Mermaid diagram to copy its code, improving instructions for users.

@haydenbleasel haydenbleasel linked an issue Aug 28, 2025 that may be closed by this pull request
@vercel
Copy link
Contributor

vercel bot commented Aug 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
streamdown Ready Ready Preview Comment Aug 28, 2025 3:49pm

@haydenbleasel haydenbleasel merged commit 593e49e into main Aug 28, 2025
6 checks passed
@haydenbleasel haydenbleasel deleted the 51-multiple-mermaid-code-block-will-show-only-last-image branch August 28, 2025 15:50
own-boldsbrain pushed a commit to own-boldsbrain/streamdown that referenced this pull request Sep 22, 2025
* Improve stable ID

* Update mermaid.tsx

* Create social-bugs-doubt.md
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 this pull request may close these issues.

Multiple mermaid code block will show only last image

1 participant