Selection is lost on Safari when editor is blured

I noticed a strange behavior on Safari :

When the focus is moved ouside of pm editor the selection is lost. Even if I does not selection something or move the focus in another editable element.

I didn’t notice this behavior on other browser (Chrome, FF, Edge or IE).

This seems to be Webkit’s native behavior—you see the same with a plain contentEditable element. When the focus is moved into an element with the keyboard, Webkit resets the selection to the start of the element. ProseMirror will then read out this DOM selection and sync its selection model to match.

I agree it’s kind of annoying behavior, but it seems to be intentional and I’m not sure it’s worth adding a hack to try and suppress it.

Hey @marijn, is there a way we can configure ProseMirror to not read out DOM selection on refocus? I’m running into this exact behavior on Safari. My use case is when a user types with nothing focused, I automatically focus the editor - the issue here is, the selection then goes to the start on Safari and therefore so does user input, even if I already have content in the editor.

I could setTimeout and move the selection to the end (50ms seems to do it) but it still introduces noticeable cursor flicker and if the user types quickly enough input will continue being inserted at the front.

EDIT: I was able to use handleDOMEvents to hook into the focus event and set the caret in the contenteditable to the end to stop this behavior, for anyone who finds this post

How are you focusing the editor? Calling EditorView.focus should not cause the DOM selection to be read.