diff --git a/.changeset/green-penguins-check.md b/.changeset/green-penguins-check.md new file mode 100644 index 000000000..bb039902b --- /dev/null +++ b/.changeset/green-penguins-check.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Disabled the auto scroll behaviour when the editor has any active selection diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index bbdc35a3e..d72985420 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -1328,12 +1328,19 @@ const defaultScrollSelectionIntoView = ( editor: ReactEditor, domRange: DOMRange ) => { - const leafEl = domRange.startContainer.parentElement! - leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange) - scrollIntoView(leafEl, { - scrollMode: 'if-needed', - }) - delete leafEl.getBoundingClientRect + // This was affecting the selection of multiple blocks and dragging behavior, + // so enabled only if the selection has been collapsed. + if ( + !editor.selection || + (editor.selection && Range.isCollapsed(editor.selection)) + ) { + const leafEl = domRange.startContainer.parentElement! + leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange) + scrollIntoView(leafEl, { + scrollMode: 'if-needed', + }) + delete leafEl.getBoundingClientRect + } } /**