From 9c97c3558715666a132f3592be0c54fe4015786e Mon Sep 17 00:00:00 2001 From: Vsevolod Rodionov Date: Mon, 27 Dec 2021 16:47:31 +0300 Subject: [PATCH] Fix: when switching between editors, Slate selection and DOM Selection can mismatch which causes React to break --- packages/slate-react/src/components/editable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index 7cb059b9bfa..ab4aea45ad2 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -214,7 +214,7 @@ export const Editable = (props: EditableProps) => { // Otherwise the DOM selection is out of sync, so update it. state.isUpdatingSelection = true - const newDomRange = selection && ReactEditor.toDOMRange(editor, selection) + const newDomRange = selection && hasDomSelectionInEditor && ReactEditor.toDOMRange(editor, selection) if (newDomRange) { if (Range.isBackward(selection!)) {