Skip to content

posAtDOM error when editor view remounts (locale/editable change) #2327

@yannishin

Description

@yannishin

Describe the bug

When the editor view is remounted (e.g., changing collaboration or ``localeoreditable` props), a console error occurs if the mouse cursor is positioned over the editor area:

Uncaught Error: [tiptap error]: The editor view is not available. Cannot access view['posAtDOM']. The editor may not be mounted yet.
at Object.getLinkAtElement (TrailingNode-*.js)
at HTMLDivElement.d (blocknote-react.js)

The error is thrown from getLinkAtElement function which is called on mouse events without checking if the editor view is available.

Note: The editor functionality works correctly - only the console error appears.

To Reproduce

  1. Create a BlockNote editor
  2. Position your mouse cursor over the editor content area
  3. Change the locale prop (e.g., 'en' → 'ko') or toggle editable (true → false → true)
  4. Observe the console error

This does NOT happen when changing the theme prop (which doesn't trigger view remount).

Misc

  • Node version: 22.x
  • Package manager: pnpm 10.x
  • Browser: Chrome : 143.0.7499.170
  • BlockNote version: 0.45.0 (also tested on 0.43.0, 0.44.0)
  • Works fine on 0.42.3

This issue started occurring after v0.43.0 ("Extensions, UI redesign" #2143).

Suggested fix:

Add a view availability check before accessing posAtDOM:

// In getLinkAtElement or the mouse event handler
if (!editor._tiptapEditor?.view) return null;
  • I'm a sponsor and would appreciate if you could look into this sooner than later 💖

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect or unexpected behavior in existing functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions