diff --git a/.changeset/forty-tools-joke.md b/.changeset/forty-tools-joke.md new file mode 100644 index 0000000000..46b2168f55 --- /dev/null +++ b/.changeset/forty-tools-joke.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Do not move selection outside inline node when composition starts diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index 093b703304..d38944617b 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -1190,26 +1190,9 @@ export const Editable = (props: EditableProps) => { setIsComposing(true) const { selection } = editor - if (selection) { - if (Range.isExpanded(selection)) { - Editor.deleteFragment(editor) - return - } - const inline = Editor.above(editor, { - match: n => - Element.isElement(n) && Editor.isInline(editor, n), - mode: 'highest', - }) - if (inline) { - const [, inlinePath] = inline - if (Editor.isEnd(editor, selection.anchor, inlinePath)) { - const point = Editor.after(editor, inlinePath)! - Transforms.setSelection(editor, { - anchor: point, - focus: point, - }) - } - } + if (selection && Range.isExpanded(selection)) { + Editor.deleteFragment(editor) + return } } },