Skip to content

fix(react): invalidate node views when editability changes - #3318

Merged
nperez0111 merged 3 commits into
fix/issue-3291-read-only-inline-math-popupfrom
fix/issue-2134-react-node-view-editability
Nov 19, 2026
Merged

nperez0111 merged 3 commits into
fix/issue-3291-read-only-inline-math-popupfrom
fix/issue-2134-react-node-view-editability

Conversation

@nperez0111

@nperez0111 nperez0111 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Stack

Merge in order:

  1. refactor(core): centralize editor editability and remove ReadOnlyExtension #3303 — centralize editor editability and replace ReadOnlyExtension with editing locks (squash-merged into main).
  2. fix(core): keep inline math source popups closed in read-only editors #3293 — keep inline math source popups closed in read-only editors (rebased onto main; merge first).
  3. This PR — invalidate React node views on editability changes (rebased on fix(core): keep inline math source popups closed in read-only editors #3293).

This PR targets the branch of #3293; its diff contains only the React node-view fix and regression coverage.

Summary

Fixes #2134: custom React node views reading editor editability could remain stale after it changed without a document update.

  • Subscribe live React block, frame, and inline-content node views to editor.onEditableChange using useSyncExternalStore.
  • Keep the existing render API: renderers read props.editor.isEditable; no additional editability prop is introduced.
  • Re-render on application editability and editing-lock changes without modifying the document or remounting for direct API changes.
  • Keep the existing portal implementation and BlockNoteView editable-prop mount lifecycle unchanged.
  • Cover the direct setter, view prop, editing locks, unchanged document/selection, and preserved local state for direct invalidation in real browsers. Renderers in the regression tests read props.editor.isEditable directly.

Validation

  • Original regression verified red-first: both cases fail without the node-view subscriptions.
  • Fresh Docker run after removing the redundant editability prop: 84 tests passed across Chromium, Firefox, and WebKit, including existing frame/layout/inline-content and math/diagram popup tests, with no retries:
    bash tests/docker-run.sh -e CI=1 -- --run ReactNodeView.editability.browser.test.tsx ReactBlockSpec.frame.browser.test.tsx ReactBlockSpec.layout.browser.test.tsx ReactInlineContentSpec.browser.test.tsx sourcePopup.browser.test.tsx --retry=0
  • Type-aware lint, formatting check, git diff --check, and commit-hook vp check --fix passed.

@vercel

vercel Bot commented Nov 9, 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 Nov 19, 2026 2:39pm UTC
blocknote-website Ready Ready Preview Nov 19, 2026 2:39pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Custom block, frame, and inline render props now expose isEditable. Static rendering passes the editor’s current value. Live node views subscribe to editability changes and update their render props. Browser tests cover setter and view prop changes, editing locks, and preserved editor state.

Changes: React render editability

Layer / File(s) Summary
Render props and static rendering
packages/react/src/schema/ReactBlockSpec.tsx, packages/react/src/schema/ReactInlineContentSpec.tsx
Block, frame, and inline render props include isEditable. Static rendering paths pass the editor’s current value.
Live node views and editability updates
packages/react/src/schema/useNodeViewEditability.ts, packages/react/src/schema/ReactBlockSpec.tsx, packages/react/src/schema/ReactInlineContentSpec.tsx, packages/react/src/schema/ReactNodeView.editability.browser.test.tsx
The hook subscribes to editability changes. Live node views pass the current value to their renderers. Browser tests cover setter and view prop changes, editing locks, and preserved document, selection, and block view state.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant Editor
  participant EditabilityHook
  participant NodeViews
  participant Renderers
  Editor->>EditabilityHook: emit editability change
  EditabilityHook->>NodeViews: update isEditable snapshot
  NodeViews->>Renderers: pass isEditable render prop
Loading

Suggested reviewers: matthewlipski

Merge Risk: Minimal · up to dbde5

Custom React node views now update when editability changes, including through editing locks, without requiring a document change. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description follows the repository template closely. It has a clear Summary explaining the fix for #2134, with stacking and merge-order notes. It covers the Changes (subscriptions via useSyncExter… 1) Resolve the conflict between the PR description and the code evidence. The description says renderers read props.editor.isEditable and that no new editability prop is added. The raw summary and PR objectives say that isEditable is added …
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: React node views now re-render when editability changes. It matches the linked issue #2134 and the objectives. It uses the conventional commit format and is specific e…
Linked Issues check Passed Objective [#2134]: custom React blocks must re-render when editor editability changes, without a user interaction.

Stack contributions:
- #3303 (r…
Out of Scope Changes check Passed Changes introduced by this PR, compared with the whole-PR merge base 90a298e, are:
- packages/react/src/schema/useNodeViewEditability.ts (new hook): subscribes to editability changes. It has no unre…
Full details: Title check

Explanation

The title names the main change: React node views now re-render when editability changes. It matches the linked issue #2134 and the objectives. It uses the conventional commit format and is specific enough for a teammate scanning history.

Full details: Linked Issues check

Explanation

Objective [#2134]: custom React blocks must re-render when editor editability changes, without a user interaction.

Stack contributions:

  • #3303 (reviewed, summary only): adds BlockNoteEditor.onEditableChange and centralizes editability in StateManager. It notifies subscribers only when effective editability changes.
  • #3318 (current PR, head dbde51a): packages/react/src/schema/useNodeViewEditability.ts subscribes to editor.onEditableChange through useSyncExternalStore, with editor.isEditable as the snapshot. ReactBlockSpec.tsx and ReactInlineContentSpec.tsx call this hook in the live node views. A subscription change re-renders the node view, which calls the custom render again.
  • #3293 (uncertain): its listed scope concerns inline math popup behavior. It does not contribute to this objective, so its missing review does not block this verdict.

Assessment: the mechanism covers the issue requirement. The issue reproduction reads props.editor.isEditable. This is inferred from the hook design, because the regression tests read the new props.isEditable prop instead. The exact issue reproduction has no dedicated test in this PR. The incremental diff from the previous reviewed head could not be read, so the hook was checked directly at head and the earlier conclusion was kept.

Regression coverage: ReactNodeView.editability.browser.test.tsx covers the direct setter, the view prop, editing locks, unchanged document and selection, and preserved local state. The author reports these tests fail without the subscriptions and pass in a three-browser Docker run.

Full details: Out of Scope Changes check

Explanation

Changes introduced by this PR, compared with the whole-PR merge base 90a298e, are:

  • packages/react/src/schema/useNodeViewEditability.ts (new hook): subscribes to editability changes. It has no unrelated logic.
  • ReactBlockSpec.tsx and ReactInlineContentSpec.tsx: add isEditable to render, frame, and inline-content props. They wire the hook into live node views and pass the current value on static paths. These changes implement [#2134].
  • ReactNodeView.editability.browser.test.tsx (new): regression coverage for [#2134].

The new public prop isEditable is a deliberate API addition, stated in the PR description and objective. It is not an unrelated change. The stack PRs #3303 and #3293 are not counted as changes of this PR. The incremental diff could not be read, so this verdict relies on the whole-PR summary and the hook file read at head.

Full details: Description check

Explanation

The description follows the repository template closely. It has a clear Summary explaining the fix for #2134, with stacking and merge-order notes. It covers the Changes (subscriptions via useSyncExternalStore, renderers read props.editor.isEditable, no new editability prop), Impact (portal implementation and BlockNoteView mount lifecycle unchanged), and Testing (red-first regression, a 84-test Docker run across three browsers, lint and format checks). The Checklist, Screenshots/Video, and Additional Notes sections are missing or not filled in. The checklist items are not ticked, and there is no statement that documentation was updated or that new unit tests were added beyond the browser test. The Rationale section is not present as a labeled section. The description also does not mention the public API surface change (isEditable added to ReactCustomBlockRenderProps, ReactCustomBlockFrameProps, and ReactCustomInlineContentRenderProps), which a reviewer would need to know. The raw summary and the PR objectives describe a typed props.isEditable field, while the PR description says renderers read props.editor.isEditable and no additional prop is introduced. This conflict must be resolved before merge.

Resolution

  1. Resolve the conflict between the PR description and the code evidence. The description says renderers read props.editor.isEditable and that no new editability prop is added. The raw summary and PR objectives say that isEditable is added to ReactCustomBlockRenderProps, ReactCustomBlockFrameProps, and ReactCustomInlineContentRenderProps. Confirm which is correct, and update the description to match the final API. 2) Add a Rationale section that explains why live node views must subscribe to editability changes. 3) Add the public API changes to the Changes or Impact section. 4) Complete the Checklist: state whether documentation was updated, and tick or explain each item. 5) Fill in Screenshots/Video or state that they do not apply. 6) Add any Additional Notes, such as the stacked PR merge order and the status of #3303 and #3293.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the editor’s state
“Editable” hops through the render gate
“Readonly” follows when locks appear
The views update and keep state clear
Then green returns, and carrots celebrate

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e206971e-5936-4ebd-aaa5-43bf3bdde23b
Commits

Reviewing files that changed from the base of the PR and between 853f262 and dbde51a.

Files selected for processing: 1

  • packages/react/src/schema/ReactBlockSpec.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

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

@blocknote/code-block

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

@blocknote/core

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

@blocknote/diagram-block

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

@blocknote/mantine

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

@blocknote/math-block

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

@blocknote/react

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

@blocknote/server-util

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

@blocknote/shadcn

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

@blocknote/xl-ai

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

@blocknote/xl-docx-exporter

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

@blocknote/xl-email-exporter

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

@blocknote/xl-multi-column

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

@blocknote/xl-odt-exporter

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

@blocknote/xl-pdf-exporter

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

@blocknote/xl-typst-exporter

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

commit: dbde51a

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2

QR code for preview link

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

Built to branch gh-pages at 2026-11-19 14:59 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@nperez0111
nperez0111 merged commit e6395e4 into main Nov 19, 2026
24 of 25 checks passed
@nperez0111
nperez0111 deleted the fix/issue-2134-react-node-view-editability branch November 19, 2026 14:40

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — 5d1ac386 Deployed Nov 19, 2026 by vercel[bot]
Preview – blocknote — 5d1ac386 Deployed Nov 19, 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.

Custom blocks do not rerender on editor.isEditable change

1 participant