Skip to content

Cannot find node position with custom blocks and shadcn #2106

@kegesch

Description

@kegesch

Describe the bug
There is a rendering error once a a block with a custom schema is in the content and certain Shadcn Components are also rendered:

Uncaught Error: Cannot find node position
    at $t (internal.ts:100:11)
    at ReactNodeViewRenderer.className (ReactBlockSpec.tsx:265:31)
    at Object.react_stack_bottom_frame (react-dom-client.development.js:25904:20)
    at renderWithHooks (react-dom-client.development.js:7662:22)
    at updateFunctionComponent (react-dom-client.development.js:10166:19)
    at beginWork (react-dom-client.development.js:11778:18)
    at runWithFiberInDEV (react-dom-client.development.js:871:30)
    at performUnitOfWork (react-dom-client.development.js:17641:22)
    at workLoopSync (react-dom-client.development.js:17469:41)
    at renderRootSync (react-dom-client.development.js:17450:11)

I initially thought that this might have to be connected with portals, as those component per default use portals and which might confuse tiptap / prosemirror's getPos function to resolve the actual elements position after the component that uses portals has rendered.
But even if I remove the portals it does not work and also only with custom blocks.

To Reproduce
https://stackblitz.com/~/github.com/kegesch/blocknote-shadcn-bug?file=src/App.tsx

  • Include certain shadcn components e.g. DropDown(MenuContent) and the BlockNoteView and include a custom block in the initialContent.

Misc

  • Node version: v22.15.0
  • Package manager: pnpm
  • Browser: edge
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions