fix: disable default UI when no components context is found#2611
fix: disable default UI when no components context is found#2611nperez0111 merged 2 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughBlockNoteViewComponent now reads the components context via Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/mantine
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
commit: |
nperez0111
left a comment
There was a problem hiding this comment.
I think this is fine default
4bb2d64 to
aab6e54
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/react/src/editor/BlockNoteView.tsx (1)
142-167: Please add regression coverage for the no-components-context path.This behavior is subtle and easy to regress. A focused test for
BlockNoteViewRawwithoutComponentsContext(including explicit UI-prop toggles) would lock the fix in.I can draft the test cases if you want.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/react/src/editor/BlockNoteView.tsx` around lines 142 - 167, Add a regression test that mounts/renders BlockNoteViewRaw (the raw component used in BlockNoteView) without wrapping it in ComponentsContext (i.e., ensure useComponentsContext returns undefined) and verify the computed default UI props from the BlockNoteDefaultUIProps logic: assert that when individual UI props (formattingToolbar, linkToolbar, sideMenu, slashMenu, filePanel, tableHandles, emojiPicker, comments) are left undefined they resolve to false in the no-components-context path, and that explicitly passed true/false prop values are respected; create focused cases for all toggles so the behavior in useComponentsContext and the defaultUIProps memo block is covered and guarded against regressions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/react/src/editor/BlockNoteView.tsx`:
- Around line 146-154: The current nullish-coalescing logic (e.g.,
formattingToolbar: formattingToolbar ?? (componentsContext ? undefined : false))
still allows an explicit true prop to enable UI when componentsContext is
missing; update each entry (formattingToolbar, linkToolbar, sideMenu, slashMenu,
filePanel, tableHandles, emojiPicker, comments) to first check componentsContext
and force false when it's absent, otherwise use the prop (or undefined) — i.e.,
if componentsContext is falsy return false unconditionally, else return the prop
(or undefined) so passing true cannot re-enable controllers without a
componentsContext.
---
Nitpick comments:
In `@packages/react/src/editor/BlockNoteView.tsx`:
- Around line 142-167: Add a regression test that mounts/renders
BlockNoteViewRaw (the raw component used in BlockNoteView) without wrapping it
in ComponentsContext (i.e., ensure useComponentsContext returns undefined) and
verify the computed default UI props from the BlockNoteDefaultUIProps logic:
assert that when individual UI props (formattingToolbar, linkToolbar, sideMenu,
slashMenu, filePanel, tableHandles, emojiPicker, comments) are left undefined
they resolve to false in the no-components-context path, and that explicitly
passed true/false prop values are respected; create focused cases for all
toggles so the behavior in useComponentsContext and the defaultUIProps memo
block is covered and guarded against regressions.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8fe448a5-f87d-478f-8062-286ec17d644d
📒 Files selected for processing (1)
packages/react/src/editor/BlockNoteView.tsx
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. ❌ Failed to clone repository into sandbox. Please try again. |
…ntext The previous nullish-coalescing logic allowed an explicit `true` prop to bypass the componentsContext check. Now componentsContext is checked first so UI controllers are always disabled when no components context exists. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
When using
BlockNoteViewRawto create a minimal editor, errors are thrown when the editor attempts to render default UI elements as there is no components context to create them from. This PR makes it so that if no component context is found when rendering the editor, all default UI elements are disabled.Note however that this is not a supported use case and we do not expect
BlockNoteViewRawto be used on its own.Closes #889
Rationale
While this use case is not officially supported,
BlockNoteViewRawis exported and may be useful to some.Changes
See above.
Impact
N/A
Testing
Because this is not something we officially support, no tests have been added.
Screenshots/Video
N/A
Checklist
Additional Notes
Summary by CodeRabbit