ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.62k stars 336 forks source link

Selection from outside the editor causes the editor to get into focus #1313

Closed thomas-at-perdoo closed 1 year ago

thomas-at-perdoo commented 1 year ago

Hello, I just want to report what looks like a bug. I couldn't find a configuration, CSS or HTML property to control this behaviour. Wondering if this behaviour is intended or if it's a bug and what are the workarounds.

How to reproduce

Video

https://user-images.githubusercontent.com/83944585/192509872-207b25a1-909e-4216-b0fe-f0098386b6a4.mov

Video of the same thing not happening, for example, in the Github editor:

https://user-images.githubusercontent.com/83944585/192510114-e74c0520-df25-483d-bfb4-13afbb3ff0a6.mov

marijnh commented 1 year ago

The focusing (as well as the inability to select across an editable element from bottom to top) are native Chrome behaviors (you get the same with a non-ProseMirror contenteditable element). Since it behaves differently from top to bottom I assume these are bugs in Chrome, but they don't seem disruptive enough to try and add hacks to ProseMirror to work around them. (You can of course report them if you want—occasionally they do look into bug reports.)

What ProseMirror does add is that it moves the selection into its content entirely when it receives focus. But that seems reasonable—when the editor has focus, it keeps the DOM selection in sync with its internal selection.

So I'm going to close this as not being a ProseMirror issue.