You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(react): invalidate node views when editability changes - #3318
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:
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.
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: 3 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Description check
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 checks: 3 passed
Check name
Status
Explanation
Title check
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
Objective [#2134]: custom React blocks must re-render when editor editability changes, without a user interaction.
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
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.
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.
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
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.
Stack
Merge in order:
main).main; merge first).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.
editor.onEditableChangeusinguseSyncExternalStore.props.editor.isEditable; no additional editability prop is introduced.BlockNoteVieweditable-prop mount lifecycle unchanged.props.editor.isEditabledirectly.Validation
git diff --check, and commit-hookvp check --fixpassed.