Catch failure on getting block position. #2256
Closed
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.
Summary
I was encountering a similar problem to this issue: #2106 but when I unmounted the BlockNoteView.
The problem seems to be that when the view is unmounted, the react view renderer tries to render the node one more time (not sure why). But the node still exists as does the reference, but it has been disconnected from it's parent (the document tree), causing the
getBlockFromPoscall to fail. So instead catching this failure and early exiting therendermethod prevents this from happening.A simple way to test this is to create a schema with a block created using
createReactBlockSpec- then add one of those blocks to the blocknote view. If you put the blocknote view in a toggleable state (i.e. in a popout panel) it will throw thecannot find node at positionerror when you unmount the blocknote view programmatically.Rationale
Changes
Impact
Testing
Screenshots/Video
Checklist
Additional Notes