Upon further testing, version 6.0.0 did not have this issue, but 6.0.1 does. 6.0.1 release notes describe only two changes, including:
Avoid DOM selection corruption when the editor doesn’t have focus but has selection and updates its content.
So this appears relevant. There are three commits modifying selections in between releases:
- Allow the editor to manage the DOM selection as long as it is in its … · codemirror/view@c0ac3cd · GitHub
- Further tweak selection-management heuristic · codemirror/view@42fcb91 · GitHub
- Don't crash when getSelection returns null · codemirror/view@220e75e · GitHub
That fix was developed in response to Selections and Life Cycle.
My current understanding is that the current behaviour is a side-effect of another fix, and not necessarily by design. I still don’t know how to fix/workaround this. My problem is that I have a focus listener that is beyond my control and cannot just blur the editor again, as once the focus event was emitted it is already too late.