Bug(BlockNote) Drag and drop of table blocks broken#113
Open
ihordubas99 wants to merge 4 commits intodevfrom
Open
Bug(BlockNote) Drag and drop of table blocks broken#113ihordubas99 wants to merge 4 commits intodevfrom
ihordubas99 wants to merge 4 commits intodevfrom
Conversation
…orative mode for all browsers
Member
|
@ihordubas99 Did you consider reporting that bug upstream at BlockNote? |
judithroth
requested changes
Apr 15, 2026
Contributor
judithroth
left a comment
There was a problem hiding this comment.
Like we said in the daily, this fix should preferrably go upstream (BlockNote directly), or, if that is not possible, be fixed in OpenProject.
3 tasks
…nd remove error boundary approach
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.
Ticket
https://community.openproject.org/projects/communicator-stream/work_packages/71900
What are you trying to accomplish?
Fix a crash that occurred when drag-and-dropping a table block in the BlockNote editor while in collaborative (Yjs) mode. The editor would crash and the table would disappear entirely.
Screenshots
demo-github.webm
What approach did you choose and why?
Root cause
This is a race condition between a Yjs transaction and a ProseMirror DnD transaction. When a user drags a table, y-prosemirror's sync-plugin fires _forceRerender on BlockNote while ProseMirror hasn't finished moving the block yet. At that moment, BlockNote's internal useMemo tries to read block.id - but block is undefined because it hasn't been mounted in its new position yet. This results in TypeError: Cannot read properties of undefined (reading 'id').
The error originates inside blocknote-react.js - our code is not present in the stack trace at the point of the crash. This is an upstream bug in BlockNote: their internal useMemo does not guard against undefined blocks during concurrent Yjs/ProseMirror transactions.
Fix
Added an
ErrorBoundarycomponent toop-blocknote-extensionsand wrappedOpBlockNoteEditorwith it insideOpBlockNoteContainer. When BlockNotecrashes, the
ErrorBoundarycatches the error and performs a soft remountof the editor after 50ms. The user sees no disruption — the table remains
in its new position because Yjs had already persisted the change before the
render crash occurred.
The boundary only triggers a remount for the known BlockNote bug, identified
by matching both the error message and
useMemoin the stack trace:Cannot read properties of undefined (reading 'id')can't access property "id", r.block is undefineduseMemois a React API name and is never minified, making it a stableanchor regardless of how the bundler renames BlockNote's internal files.
Matching both conditions avoids swallowing unrelated crashes - if the error
does not match the known pattern,
hasErrorstaystrueand the fallbackis shown, so real bugs remain visible during development.
This is intentionally a workaround. The error is left visible in the console
so we can monitor when BlockNote fixes this upstream and remove the boundary.
The error is intentionally left visible in the console so we can monitor if
it disappears once BlockNote fixes this upstream.
Merge checklist