diff --git a/.changeset/healthy-lizards-clap.md b/.changeset/healthy-lizards-clap.md new file mode 100644 index 0000000000..cb2a871568 --- /dev/null +++ b/.changeset/healthy-lizards-clap.md @@ -0,0 +1,5 @@ +--- +"slate-react": patch +--- + +fix: Prevent domSelection.collapseToEnd crash in setDomSelection diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index 2988208a9a..a1ba82e32d 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -416,7 +416,11 @@ export const Editable = forwardRef( selection && ReactEditor.toDOMRange(editor, selection) if (newDomRange) { - if (ReactEditor.isComposing(editor) && !IS_ANDROID) { + if ( + ReactEditor.isComposing(editor) && + hasDomSelection && + !IS_ANDROID + ) { domSelection.collapseToEnd() } else if (Range.isBackward(selection!)) { domSelection.setBaseAndExtent(