Fix selection when Firefox creates multi range selection across svg. #173
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Firefox selection breaks and restarts when dragging across an
svg.This issue was previous report in an unanswered thread and a JavaScript solution was written in this commit. Rewrite that JS commit in TS.
This code seems to make some assumptions that seem dodgy — why would taking the head from the first range and the anchor from the old selection give the appropriate range? When selecting from bottom to top that sounds like it won't work.
Unfortunately I am not the original author of the patch. But what I observed when I tested the original fix is that when the selection breaks to become a multi-range selection, the range order does not change whether selecting from bottom to top, or from top to bottom.
Can you still reproduce the issue on this link? With Firefox 130 Linux I don't see anything odd happening when dragging selections there.
That link was super helpful and I was able to narrow it down more. The selection only becomes mutli-range in Firefox for nodes that are
atom: true—this happens for both thesvgandbutton, as it turns out.I don't know how I forgot that fact—both times I've run into this someone was rendering uneditable labels with
svgtype icons.You mean you can reproduce it on that link with Firefox Mac, or that something had to be changed before it reproduced? Your videos aren't loading for me (but I prefer words anyway).
One line change to render as though it were
atom: true:... and it immediately starts breaking on Firefox as the selection crosses each
button.That'll break more than just selection, though—creating editable islands like this inside the content managed by ProseMirror isn't supported by this library. Nodes with a
contentDOMshould keep all ancestors of that element editable.It is the non-editable islands that are the problem, and people make those in ProseMirror all the time. Particularly for non-editable links.
For example, when
atom: truethetoDOMresult will setcontenteditable="false"on anatag. So we could imagine this node:... creating this DOM element:
If we update
toDOMto insert ansvginto thealike so:... creating this DOM:
... we end up with a DOM that breaks the selection in Firefox. And the only difference is the presence of the
svg.Note: I didn't use the
buttonexample, as the semantics of abuttoninside aais questionable, and who knows what the browser would do.Non-editable islands work fine. It's editable islands inside non-editable nodes that don't.
But I can reproduce this now. If I directly return
<svg>elements for leaf nodes, the browser doesn't do this, but if I wrap them in an additional element, it does.Does attached patch look reasonable to you?
Reverted my local patch for yours and it works perfectly.
Thank you for your patience and assistance. 🙇
Pull request closed