Skip to content

fix(core): mark a container's DOM only once - #3116

Open
YousefED wants to merge 1 commit into
container-blocks/unifiedfrom
container-blocks/mark-once
Open

YousefED wants to merge 1 commit into
container-blocks/unifiedfrom
container-blocks/mark-once

Conversation

@YousefED

@YousefED YousefED commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

(note; didn't check the specific solution, there might be cleaner ways to structure it, but I do think the problem should be addressed)

What this changes

createSpec.ts marks the DOM of a container block. The mark puts the block type, the block id and the block props on the container's root element. It also puts data-children-of on the element that holds the child blocks.

Before this change, the node view marked every container block. A React container also has an adapter. That adapter marks the author's own element a second time. Two elements then had the same block id and the same block type.

The new function markContainerStructure does the mark. Only the vanilla render path calls it. React does not use that path. A React container therefore keeps only the mark from its adapter.

What this corrects

The example custom-schema/container-block shows the effect. These are the counts for the panel block:

Count Before After
Elements with the block id 2 1
Elements with data-children-of 2 1

A regular block still has two elements with the block id. These are blockOuter and blockContainer. The block selector ignores blockOuter, and one element stays.

This fix is also mentioned in the comment on BlockPopover in the original PR (and the suggested fix builds on this PR)

The other files

Three files get new comments only:

  • containerAttributes.ts names the counterpart of applyContainerAttributes.
  • internal.ts points from wrapInBlockStructure to the container path.
  • useNodeViewBlock.ts explains the condition on the bnBlock group.

One file gets a guard. multiColumnHandleDropPlugin.ts throws an error if the target column is not a child of its column list. The code reads both from the same document, so an absent column shows a fault. Without the guard, the code puts the new column at the wrong index.

Tests

  • packages/core: 932 tests pass.
  • packages/xl-multi-column: 103 tests pass.
  • vp lint --type-aware: no problems.

🤖 Generated with Claude Code

The node view marked every container block. The React adapter marked its
containers a second time, on the author's own element. Two elements then
carried the same block id and the same block type.

Move the marking into the vanilla render path, which React does not use.
Each container now has one element with its identity.

Also add a guard to the multi-column drop handler, and point four comments
at their counterparts.
@vercel

vercel Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Sep 23, 2026 6:48pm UTC
blocknote-website Ready Ready Preview Sep 23, 2026 6:48pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 7a5ee992-765b-4411-8dd0-a8136b4f50c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3116

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3116

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3116

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3116

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3116

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3116

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3116

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3116

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3116

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3116

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3116

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3116

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3116

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3116

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3116

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3116

commit: 997c060

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-3116/

Built to branch gh-pages at 2026-09-23 19:07 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@YousefED
YousefED requested a review from nperez0111 September 23, 2026 18:58

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — 997c060f Deployed Sep 23, 2026 by vercel[bot]
Preview – blocknote — 997c060f Deployed Sep 23, 2026 by vercel[bot]
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.

1 participant