fastmail/Squire

Cursor position bug after link('a' element) paste in Firefox

SergeyMosin opened this issue · 0 comments

Cursor jumps to the beginning of a line (see the video) when an 'a' element is pasted after some text in Firefox (Chrome is unaffected)

It looks like Firefox does not like the cursor/range being set to between the end of a element and the end of parent block ( ex: <div>some text: <a>some link</a>|</div> ) in the moveRangeBoundaryOutOf function

const moveRangeBoundaryOutOf = (

However if the fixCursor function is called on line 174 everything works

        if (clone.endContainer === parent) {
            fixCursor(parent) // << ADD THIS ON LINE 174
            range.setStart(clone.endContainer, clone.endOffset);
            range.setEnd(clone.endContainer, clone.endOffset);
        }

The parent looks like this now <div>some text: <a>some link</a>|<br></div> before the range is set and the cursor behaves normally in Firefox

firefox-link-paste-bug.webm