Repository navigation
Let wide mermaid diagrams scroll horizontally - #842
Merged
pikann merged 1 commit intoDec 1, 2026
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
✅ 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 rootdivnow carriesw-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-contentflex-item constraint for future readers.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
pikann
approved these changes
Dec 1, 2026
pikann
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀
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.

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 isdisplay: flex; width: 100%(row direction). The mermaid block's rootdivis therefore a flex item, and a flex item'smin-widthdefaults toauto, 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'soverflow-hiddenclips it. The inner scroll container is as wide as the SVG, so there is nothing to scroll.Fix
Add
w-full min-w-0to the block's rootdivso it stays at the editor's width; the existingoverflow-x-autowrapper 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-contentflex wrapper around a 1400px SVG inside a 700pxoverflow-hiddeneditor: without the change the SVG is clipped with no scrollbar; with it, a scrollbar appears and the diagram scrolls to its end.biome checkandtsc --noEmitpass inapps/web.