Caret position after nodeview insert on empty line

I’m seeing some behavior I don’t understand within prosemirror. Any help is appreciated.

I have code that inserts a nodeview and empty space before a word when a new character to start a new word is typed. See screen recording below.

The code works except when the user starts typing on an empty new line. In this case, the caret gets put in front of the most recently typed character and I can’t move the caret past the character unless I type another character.


  1. Move caret to an empty line
  2. Type a single character
  3. A node view and text node containing a space is inserted before the typed character
  4. Caret is before the character in step 2 and can’t move to the end of the character in step 2
  5. Type any character, the character is inserted and everything is back to normal

I’m inserting the nodeview and space at the same position using sequential insert commands:

tr = tr.insert(
  state.schema.text(' ')

tr = tr.insert(

Screen grab of the issue showing two behaviors:

  1. Type a character, wait for nodeview + space insert, type another character
  2. Type a character, wait for nodeview + space insert, move back one position, move forward one position, type another character:

caret position nodeview insert

Does this happen across browsers? There’s quite a bunch of cursor-drawing bugs in various browsers, and they often happen around uneditable nodes.

Apologies for not adding that, it’s happening in chrome but not firefox (mac).

Is there a best practice around solving these types of browser specific issues in prosemirror? I’m at a little bit at a loss on how to tackle the core issue.

The library contains a bunch of hacks to try and work around these kind of issues, but I guess this one isn’t being detected. Generally, resetting the DOM selection solves these in Chrome. Could you try to create the smallest possible script that demonstrates the problem? I can try to see why the regular hack isn’t kicking in then.