Inserting text at end of link causes window.getSelection().anchorNode to move from #text to p

This issue appears to only affect Chrome, not Firefox. It causes problems when we need to position an element based on window.getSelection().

Any thoughts @marijn? Is this an expected variation in contentEditable behavior across browsers or something we should expect ProseMirror to normalize?

You can reproduce it on this page: Link – Tiptap

When you type anywhere inside of a link or place the caret at the end and run document.querySelector('iframe').contentWindow.getSelection() you’ll see #text for the anchorNode but if you type at the end of a link you’ll see it change to p.

Why is this a problem for you? Generally, DOM selection positions that differ only in which side of an inline boundary they are on can be considered equivalent.

Thanks for your reply @marijn.

We use floating-ui’s detectOverflow and this causes it to change the overflow calculations flipping a -100 top value to a +100 instead. I’m working around it by using view.coordsAtPos for now but the behavior seemed unexpected to me. This sort of behavior doesn’t occur with any other mark types.