Cursor jumps from the line end to widget decorator


Hi @marijn! ProseMirror is fantastic project, thank you for your awesome work.

I stuck with the following issue:

When there is a widget decoration on the line
 and user type something to the end of the line
 and external view.updateState(..) is happening (e.g. some event from collaboration service)

input cursor jumps to the position of the latest widget in the line.

I extracted the problem to the following snippet:!/deep-canid


  • it looks like the issue is reproduced in Chrome only (tested in Firefox and Safari - it works well).
  • if start typing in the middle of the line - it works as expected.
  • if disable widget plugin - cursor behavior is consistent.

Can you assist on the issue? I lost hope trying to debug a problem.

Thank you in advance / Vladimir

Native browser cursor "jumps" when there is a widget at the same position
In collab setup with selections, cursor jumps to a different position without selection being changed

Thanks for providing a demo. When this happens, the DOM selection as reported by the selection object is actually at the end of the line… but the cursor is shown before the text node, and subsequent typing does end up there. So there’s definitely a browser bug involved.

The question is what is triggering it and if we can work around it. Your demo is constantly causing DOM updates because of the way it creates its widget decorations (they cannot be considered equivalent to an earlier version because the editor can’t prove that the render functions are the same). You can add a key: pos to the last argument to Decoration.widget to fix that, which will speed up rendering and work around this issue (usually, I suppose).

That’s not fixing the root cause though. You could try creating a simple ProseMirror-less demo that reproduces the issue by replaying the same DOM interactions (replace the widget, twice, with plain JS when you type), and if that works, report a bug to the Chrome team.