Skip to content

Cannot find node position with custom blocks and shadcn #2106

Closed

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 💖

Activity

  1. mehdigmira commented on Oct 16, 2025

    @mehdigmira

    Same here ! Any workaround would be much appreciated

  2. mehdigmira commented on Oct 16, 2025

    @mehdigmira

    Ok instead of setting initial content, setting it in a setTimeout(() => editor.replaceBlocks(editor.document, savedContent), 0) seems t be working

  3. nperez0111 commented on Oct 17, 2025

    @nperez0111
    Contributor

    Hm, this is pretty surprising to me too. For some reason commenting out the shadcn components makes the editor work again. Maybe Prosemirror cannot find the DOM position or something? I didn't see it have an additional render or anything.

    @matthewlipski might know more here

  4. kegesch commented on Oct 27, 2025

    @kegesch
    Author

    @nperez0111 Thank you very much for the fix. It works. But it think something else is now broken, see #2134.

  5. AmayerGogh commented on Dec 18, 2025

    @AmayerGogh

    Same here !
    Error: Cannot find node position
    at kt2 (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)

  6. xu4wang commented on Dec 20, 2025

    @xu4wang

    Ok instead of setting initial content, setting it in a setTimeout(() => editor.replaceBlocks(editor.document, savedContent), 0) seems t be working

    Thanks. it works for me..

  7. xu4wang commented on Dec 20, 2025

    @xu4wang

    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 💖

    It's not related to Shadcn, I'm testing with the Alert Block, https://www.blocknotejs.org/examples/custom-schema/alert-block-full-ux, and encountering the same issue.

  8. YousefED commented on Dec 20, 2025

    @YousefED
    Collaborator

    @xu4wang could you share a reproducible example, on the latest version of BlockNote?

    Best is to provide an online sandbox, click to create one

  9. xu4wang commented on Dec 20, 2025

    @xu4wang

    @xu4wang could you share a reproducible example, on the latest version of BlockNote?

    Best is to provide an online sandbox, click to create one

    Hi @YousefED

    please find below the code and my package.json
    alert.tsx
    package.json

  10. nperez0111 commented on Dec 20, 2025

    @nperez0111
    Contributor

    @xu4wang, this isn't really a complete example

  11. xu4wang commented on Dec 21, 2025

    @xu4wang

    @xu4wang, this isn't really a complete example

    Sorry the project I am working on is a complex one, with backend services required to be running properly. I will be working on a minimal reproduceble project and will post here when ready.

  12. spe987-create commented on Dec 21, 2025

    @spe987-create

    I have the same issue. Everytime I try to load React rendered block, this happens:

    Image

    My Blocnote package versions:

    "@blocknote/code-block": "^0.45.0",
    "@blocknote/core": "^0.45.0",
    "@blocknote/react": "^0.45.0",
    "@blocknote/shadcn": "^0.45.0",

    setTimeout(() => editor.replaceBlocks(editor.document, savedContent), 0) this workaround fixes the issue for me as well.

  13. nperez0111 commented on Jan 8, 2026

    @nperez0111
    Contributor

    We have contributed a change upstream in Tiptap, which we believe should resolve the issue. If you upgrade to the latest version of BlockNote: https://github.com/TypeCellOS/BlockNote/releases/tag/v0.46.0 you should automatically get the latest version of Tiptap with the change.

    Please let us know if you continue to have issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions