Fix position bounds check in updateDraggedNode #191
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-update-dragged-node-bounds-check-v2"
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?
When a document changes size during a drag operation (e.g. via collaborative editing), the stored node selection position (
sel.from) can exceed the new document's content size. Callingdoc.nodeAt()with an out-of-range position causesFragment.findIndexto throw:This adds bounds checks before both
nodeAtcalls inupdateDraggedNode. When the position is out of range, the method falls through tofound = -1, which already correctly setsthis.dragging.nodetoundefined.We've observed this crash in our production collaborative editor (Dovetail, using ProseMirror + Yjs)
Apologies for the formatting noise on the previous PR (#190)
Thanks, looks much better.