Repository navigation
fix: give mermaid diagrams a real viewport so pan and zoom works - #400
Closed
LawrenceYoong wants to merge 11 commits into
Closed
LawrenceYoong wants to merge 11 commits into
LawrenceYoong wants to merge 11 commits into
Conversation
svg-pan-zoom removes the svg viewBox, so the svg fell back to its 150px default height: only the top of the diagram showed and the control icons landed outside the visible box, unclickable. Size the frame instead, let the svg fill it, drop Mermaid's max-width cap, and contain panning.
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.
The pan and zoom added in b256a8f never worked in a real browser, and there were two separate faults.
1. The running office served a build from before the feature.
dist/publicwas built 2026-11-07 23:22; b256a8f landed 01:25. The servedask-*.jshadcontrolIconsEnabled=0, so no controls and no viewport group ever appeared in the DOM.2. Once rebuilt, the frame had no height. svg-pan-zoom deliberately removes the svg
viewBox(svg-pan-zoom.jsline 282). Mermaid setswidth="100%"and no height, so with the viewBox gone the svg fell back to the CSS default replaced-element height of 150px. The diagram was scaled to fit but clipped to its top 150px, and the control icons — positioned from the pre-removal 746×393 box — were painted outside the svg, where clicks could not reach them.This PR sizes the figure into a real viewport (
height: clamp(180px, 38vh, 480px)), lets the svg fill it, drops Mermaid's natural-widthmax-widthcap, and turns oncontainso panning cannot drag the diagram out of view.Verified in headless Chrome against the live office (
docs/roadmap/architecture.md, 2177×1134 natural, anddocs/manual/T03-transfer.md, 877×371):npm run typecheckpasses.npm testhas one failure,tests/repos.test.ts"O opens a pull request in each repository" — it fails identically on plainorigin/main(checked by stashing this change), so it is pre-existing and unrelated.