fix(mermaid): make the download control reachable in the Mermaid fullscreen view#552
Open
dkachur1 wants to merge 1 commit into
Open
fix(mermaid): make the download control reachable in the Mermaid fullscreen view#552dkachur1 wants to merge 1 commit into
dkachur1 wants to merge 1 commit into
Conversation
…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.
Contributor
|
@dkachur1 is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a Mermaid diagram is expanded to fullscreen, there is no way to download it — the download button disappears entirely.
Root cause
MermaidFullscreenButtonrenders its overlay viacreatePortal(..., document.body). The block's action toolbar (MermaidDownloadDropdown, copy button,MermaidFullscreenButtonitself) is rendered as a sibling of the diagram insidecomponents.tsx, outside that portal. Since the portal isfixed 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 aclosest()DOM lookup failed; for Mermaid the fullscreen view never rendered a download control in the first place.Fix
Render
MermaidDownloadDropdowninside the fullscreen portal, next to the exit button, respecting the existingcontrols.mermaid.downloadconfig (mirrors the same inline boolean-resolution pattern already used forpanZoomin this file). Propagation is stopped on the wrapping div so clicking download doesn't also trigger the backdrop's close-on-click handler.Testing
mermaid-fullscreen.test.tsx:controls.mermaid.downloadisfalsemermaid.test.tsx,mermaid-component.test.tsx,mermaid-download.test.tsx,mermaid-fullscreen.test.tsxpass (56/56).biome checkclean on both changed files.Added a changeset.