1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-19 21:01:57 +02:00

Fix: when switching between editors, Slate selection and DOM Selection can mismatch which causes React to break (#4749)

This commit is contained in:
Vsevolod Rodionov 2022-01-19 17:53:26 +03:00 committed by GitHub
parent 9f3aee5536
commit a3dfb151d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fix "cannot resolve DOM point" error when switching between multiple errors

View File

@ -214,7 +214,10 @@ 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!)) {