fix(ux): add min-height to mermaid diagram viewport on mobile (#5525) - #5560
2 commits merged into
Conversation
…na#5525) The mermaid-viewer-viewport has position:relative with an absolutely-positioned canvas child, so it collapses to 0 height on narrow mobile screens where the SVG hasn't loaded yet. Add min-height:200px so diagrams are visible while rendering. Fixes nesquena#5525 Co-Authored-By: Claude <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| static/style.css | Adds a mobile-scoped media query (max-width: 640px) that applies min-height: min(200px, 70vh) to .mermaid-viewer--inline .mermaid-viewer-viewport, preventing the absolutely-positioned canvas container from collapsing to 0 height before the SVG renders. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Mermaid diagram inserted into DOM] --> B{Viewport width}
B -- wider than 640px --> C[Height driven by JS after SVG renders]
B -- 640px or narrower --> D[min-height applied via media query\nContainer stays visible before SVG loads]
C --> E[SVG renders, JS sets canvas dimensions]
D --> E
E --> F[User pans and zooms the diagram]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Mermaid diagram inserted into DOM] --> B{Viewport width}
B -- wider than 640px --> C[Height driven by JS after SVG renders]
B -- 640px or narrower --> D[min-height applied via media query\nContainer stays visible before SVG loads]
C --> E[SVG renders, JS sets canvas dimensions]
D --> E
E --> F[User pans and zooms the diagram]
Reviews (2): Last reviewed commit: "fix(ux): scope mermaid min-height to inl..." | Re-trigger Greptile
🎬 Cutter preview — PR #5560
|
🔬 Gate certification — RED ⛔ (the min-height is GLOBAL, not mobile-only — can break the lightbox fit-to-screen on short viewports — 1 SILENT)Certified head: What I ran (rebased worktree
|
| Gate | Result |
|---|---|
| Rebase onto current master | ✅ git apply clean; diff = static/style.css 1 line |
| Codex (reproduce) | SHIP-WITH-FIXES — 1 SILENT (global min-height breaks lightbox); Codex verified the media-block boundary |
| Full suite | skipped (1-line CSS, no code path) — Codex + scope check is the gate |
Findings
⛔ SILENT (Codex CONFIRMED, corrected my read) — the min-height is GLOBAL, not mobile-only (static/style.css:2399): the @media (max-width: 640px) block CLOSES at line 2377, so the .mermaid-viewer-viewport rule at 2399 is a base/global rule (not inside the media query, despite the title "on mobile"). min-height:200px thus applies to both inline AND .mermaid-viewer--lightbox. The lightbox JS sets height:90vh (ui.js:1620-1622) and CSS caps it (style.css:2402), but the new global min-height overrides that when 90vh < 200px (a window shorter than ~222px) — breaking the fullscreen "fit to screen" envelope (#5413 inline-vs-lightbox territory). Fix (Codex-exact): remove min-height:200px from the global rule and add .mermaid-viewer--inline .mermaid-viewer-viewport{ min-height: min(200px, 70vh); } inside an ACTUAL @media (max-width: 640px) block — so it's inline-only, mobile-only, and can't exceed 70vh.
Recommendation to the next agent / author
RED — gate-fail/changes-requested (1 SILENT): scope the min-height to inline + mobile and cap it at viewport height — .mermaid-viewer--inline .mermaid-viewer-viewport{ min-height: min(200px, 70vh); } inside a real @media (max-width:640px) block; do NOT put min-height on the global .mermaid-viewer-viewport (it leaks into the lightbox and can override height:90vh on short viewports). The fix for #5525 (collapsing inline viewport) is worthwhile — it just needs the correct scope (the current rule is global despite the "on mobile" title). concept 4/5 (real fix, wrong scope). Author @nankingjing (new). crit=3. (Gate value + a self-correction: verify a CSS rule's media scope by the block's CLOSING brace, not just the nearest @media above — the @media(max-width:640px) here closed at 2377, so the 2399 rule was global; Codex caught what a nearest-open-media-above heuristic missed.)
Gate-certifier layer (warm-up → gate → release). I do not merge/tag/deploy. Rebased onto current master; Codex verified the @media(max-width:640px) block closes at style.css:2377 so the edited rule at 2399 is GLOBAL (not mobile-only) — min-height:200px leaks into .mermaid-viewer--lightbox and can override its height:90vh fit-to-screen when 90vh<200px. Fix: scope to .mermaid-viewer--inline inside a real mobile media block, cap at min(200px,70vh). Cert valid for sha:1dd915ce.
Remove min-height:200px from the global .mermaid-viewer-viewport rule (it was outside the @media(max-width:640px) block despite the PR title). Add a properly-scoped .mermaid-viewer--inline .mermaid-viewer-viewport min-height inside an actual @media(max-width:640px) block, capped at min(200px, 70vh) so it cannot override the lightbox fit-to-screen envelope.
🔬 Gate certification — GREEN ✅ · CONVERGED (round-1 global-leak brick fixed; full gate Codex + Fable-UX + suite) · ⏸️ visible mermaid → Nathan sign-offCertified head: What I ran (rebased worktree
|
| Gate | Result |
|---|---|
| Rebase onto current master (incl. #5660 flake fix) | ✅ git apply clean |
| Codex (re-verify scope, no lightbox leak) | SAFE TO SHIP — 0 findings |
| Fable-UX | SHIP-UX — inline mermaid gets sensible min-height, lightbox unaffected |
| Full pytest suite | ✅ 12178 passed, 0 failed (the 3.11-shard-4 flake that red-failed round-1 is now fixed on master via #5660) |
Findings — round-1 global-leak brick CLOSED
✅ Correctly scoped (verified by CLOSING brace, per the #5560 lesson): the min-height:min(200px,70vh) rule is INSIDE @media (max-width: 640px) (opens line 2402, single rule, closes 2404) AND scoped to .mermaid-viewer--inline .mermaid-viewer-viewport. The .mermaid-viewer--lightbox .mermaid-viewer-viewport (line 2405) is a SEPARATE rule with max-height:90vh and NO min-height — so the fullscreen/lightbox fit-to-screen is preserved (my round-1 brick concern, the #4856/#5338 global-viewport-rule-leaks-into-sibling-variant class, is fixed). Codex confirmed: applies only to inline mobile mermaid, not lightbox; media scope verified by closing brace; min(200px,70vh) sensible; desktop (>640px) unaffected; pan/zoom/touch-action intact. Fable confirmed the inline min-height looks right and the lightbox is unbricked. Full suite green.
Recommendation to the next agent / Nathan
GREEN — merge from branch gate-rebase/5560-mermaid-minheight-inline-mobile (sha:292685a6), NOT the PR's stale head 49d54e0a — after a quick visual sign-off (visible mermaid mobile). Round-1 global-leak brick fixed (min-height inline+mobile-scoped, lightbox fit-to-screen preserved), full gate clean. Note: the PR-head CI was red only on the 3.11-shard-4 multitab-SSE flake (NOT this PR's fault) — that flake is now fixed on master (#5660), so a re-run/rebase clears it; my rebased branch is full-suite green. concept 4/5. crit=2.
Gate-certifier layer (warm-up → gate → release). I do not merge/tag/deploy. Round-1 global-leak brick fixed: min-height now @media(max-width:640px)+.mermaid-viewer--inline scoped (verified by closing brace), lightbox (2405) has no min-height so fit-to-screen preserved; Codex SAFE + Fable-UX SHIP-UX + full suite green (0 failed). PR-head shard-4 red was the #5660 flake (now fixed on master), not this PR. Visible → Nathan. Cert valid for sha:292685a6.
79d3b59
|
Shipped in v0.51.899. Thanks @nankingjing — inline Mermaid diagrams now get a min-height on mobile so they no longer collapse to 0 height (scoped so the lightbox + desktop are unaffected). This is the mobile-height half of #5525 (the icon half shipped earlier); #5525 stays open only for tracking closure. |

Closes #5525
Summary
Mermaid diagrams have 0 height on mobile because the viewport container (
.mermaid-viewer-viewport) hasposition:relativewith an absolutely-positioned canvas child. Without an explicit min-height, the container collapses when the SVG hasn't rendered yet.Fix
+1/-1: add
min-height:200pxto.mermaid-viewer-viewportso diagrams are visible on narrow mobile screens.Files
static/style.css—.mermaid-viewer-viewportrule