Cursor disappears when deleting to an empty code block in some browsers


I’m on v0.16.0 using the example setup and encountering an oddity in Safari and Chrome (v10.0.2 and v55 respectively) running on macOS. I can reproduce this on the Basics demo page following the steps below.

  1. Start a code block with three backticks `
  2. Enter some arbitrary character, say a
  3. Delete this character with backspace

The cursor is expected to remain at the beginning of the empty code block. However, the cursor disappears for the above browsers (FF is fine). In Chrome, I get a not very helpful The given range isn't in document error.

It appears that Chrome and Safari like to replace <code></code> with <br>. So we get <pre><br></pre> as the resulting HTML; further editing often just makes a mess. I guess ProseMirror isn’t very happy about placing the cursor following an unexpected change.

A fix could be to insist all pre elements have a code element child when rendered, but only if it adheres to the current schema. Still new to ProseMirror here, so I’m picking it may not be so simple :slight_smile:

I couldn’t find any similar issues. Is anyone else seeing this behaviour?

This is an awesome project and I take my hat off to those involved. Thanks.

Can you still reproduce this issue in 0.20.0?