Skip to content

Commit

Permalink
Check whether the anchor is in the right place when suppressing sel u…
Browse files Browse the repository at this point in the history
…pdates

FIX: Fix an issue where, if decorations changed during a pointer drag selection,
the selection anchor might move around inappropriately.

See https://discuss.prosemirror.net/t/selection-changes-when-inline-decoration-is-applied/1027/6
  • Loading branch information
marijnh committed Dec 21, 2021
1 parent 1339a3a commit c73b060
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/selection.js
Expand Up @@ -43,9 +43,13 @@ export function selectionToDOM(view, force) {
if (!editorOwnsSelection(view)) return

if (!force && view.mouseDown && view.mouseDown.allowDefault) {
view.mouseDown.delayedSelectionSync = true
view.domObserver.setCurSelection()
return
let domSel = view.root.getSelection(), curSel = view.domObserver.currentSelection
if (domSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset,
curSel.anchorNode, curSel.anchorOffset)) {
view.mouseDown.delayedSelectionSync = true
view.domObserver.setCurSelection()
return
}
}

view.domObserver.disconnectSelection()
Expand Down

0 comments on commit c73b060

Please sign in to comment.