Skip to content

Commit

Permalink
Fix: when switching between editors, Slate selection and DOM Selectio…
Browse files Browse the repository at this point in the history
…n can mismatch which causes React to break
  • Loading branch information
Jabher committed Dec 27, 2021
1 parent 735d2d0 commit 9c97c35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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!)) {
Expand Down

0 comments on commit 9c97c35

Please sign in to comment.