Skip to content

fix(mermaid): make the download control reachable in the Mermaid fullscreen view#552

Open
dkachur1 wants to merge 1 commit into
vercel:mainfrom
dkachur1:fix-mermaid-fullscreen-download
Open

fix(mermaid): make the download control reachable in the Mermaid fullscreen view#552
dkachur1 wants to merge 1 commit into
vercel:mainfrom
dkachur1:fix-mermaid-fullscreen-download

Conversation

@dkachur1

Copy link
Copy Markdown

Summary

When a Mermaid diagram is expanded to fullscreen, there is no way to download it — the download button disappears entirely.

Root cause

MermaidFullscreenButton renders its overlay via createPortal(..., document.body). The block's action toolbar (MermaidDownloadDropdown, copy button, MermaidFullscreenButton itself) is rendered as a sibling of the diagram inside components.tsx, outside that portal. Since the portal is fixed inset-0 z-50, it visually covers that toolbar, and structurally the toolbar was never included in the portal's own markup — so once fullscreen is open there's no download affordance reachable at all.

This is the same class of bug already fixed for tables in #470 (fix(table): add table-wrapper to fullscreen portal so copy/download work), closed by #468 — except for tables the buttons were present in the portal but a closest() DOM lookup failed; for Mermaid the fullscreen view never rendered a download control in the first place.

Fix

Render MermaidDownloadDropdown inside the fullscreen portal, next to the exit button, respecting the existing controls.mermaid.download config (mirrors the same inline boolean-resolution pattern already used for panZoom in this file). Propagation is stopped on the wrapping div so clicking download doesn't also trigger the backdrop's close-on-click handler.

Testing

  • Added two tests to mermaid-fullscreen.test.tsx:
    • the download button renders inside the fullscreen portal, downloads a PNG on click, and does not close the fullscreen overlay
    • the button is hidden when controls.mermaid.download is false
  • All existing tests in mermaid.test.tsx, mermaid-component.test.tsx, mermaid-download.test.tsx, mermaid-fullscreen.test.tsx pass (56/56).
  • biome check clean on both changed files.

Added a changeset.

…screen view

The Mermaid fullscreen overlay renders via createPortal to document.body,
which severs it from the block's action toolbar (download/copy/fullscreen
buttons render as siblings outside the portal). That toolbar has no way to
appear inside the portal, so once a diagram is expanded to fullscreen there
is no way to download it — same root cause as vercel#468/vercel#470, but for Mermaid
the fullscreen view never rendered the download control at all rather than
rendering it with a broken DOM lookup.

This renders MermaidDownloadDropdown inside the fullscreen portal next to
the exit button, respecting the existing controls.mermaid.download config,
with propagation stopped so downloading doesn't also close the overlay.
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@dkachur1 is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant