Skip to content

Let wide mermaid diagrams scroll horizontally - #842

Merged
pikann merged 1 commit into
Paca-AI:masterfrom
sebathi:fix/mermaid-block-horizontal-scroll
Dec 1, 2026
Merged

pikann merged 1 commit into
Paca-AI:masterfrom
sebathi:fix/mermaid-block-horizontal-scroll

Conversation

@sebathi

@sebathi sebathi commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Problem

A mermaid diagram wider than the editor is clipped at the right edge, in docs, task descriptions and comments. The block's inner wrapper already has overflow-x-auto, but it never gets a chance to scroll: the selection outline visibly extends past the editor's right edge.

Cause

BlockNote renders a React custom block inside .bn-block-content, which is display: flex; width: 100% (row direction). The mermaid block's root div is therefore a flex item, and a flex item's min-width defaults to auto, i.e. the min-content width of its contents. Since the SVG is kept at its natural size (max-w-none), the item grows to the diagram's full width, overflows the editor, and the document container's overflow-hidden clips it. The inner scroll container is as wide as the SVG, so there is nothing to scroll.

Fix

Add w-full min-w-0 to the block's root div so it stays at the editor's width; the existing overflow-x-auto wrapper then shows a horizontal scrollbar. One class change plus a comment explaining the flex constraint.

Verified with a standalone page reproducing BlockNote's .bn-block-content flex wrapper around a 1400px SVG inside a 700px overflow-hidden editor: without the change the SVG is clipped with no scrollbar; with it, a scrollbar appears and the diagram scrolls to its end.

biome check and tsc --noEmit pass in apps/web.

BlockNote renders a custom block inside .bn-block-content, a row flex
container, so the mermaid block's root div is a flex item whose min-width
defaults to auto. With the SVG at its natural width (max-w-none) the item
grew to the diagram's width, overflowed the editor and got clipped by the
document container's overflow-hidden, leaving the inner overflow-x-auto
wrapper nothing to scroll.

Constrain the root div with w-full min-w-0 so it stays at the editor's
width and the existing scroll wrapper shows a horizontal scrollbar.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound — min-w-0 removes the flex item's automatic minimum width so the existing overflow-x-auto wrapper can finally scroll; w-full keeps the block pinned to editor width.

Reviewed changes — the single-file diff was reviewed in full, with the BlockNote flex-wrapper claim verified against @blocknote/[email protected].

  • Mermaid block flex fix: MermaidBlockView's root div now carries w-full min-w-0, so the block no longer grows to a wide SVG's natural width and the inner wrapper scrolls horizontally instead of being clipped.
  • Explanatory comment: documents the .bn-block-content flex-item constraint for future readers.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@pikann pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit 51a47d0 into Paca-AI:master Dec 1, 2026
2 checks passed
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.

2 participants