diff --git a/.changeset/modern-toes-invent.md b/.changeset/modern-toes-invent.md new file mode 100644 index 000000000..ad939eeec --- /dev/null +++ b/.changeset/modern-toes-invent.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +Fix deletion of expanded range (#4546) diff --git a/packages/slate-react/src/components/editable.tsx b/packages/slate-react/src/components/editable.tsx index 2fd805d30..4bece19a1 100644 --- a/packages/slate-react/src/components/editable.tsx +++ b/packages/slate-react/src/components/editable.tsx @@ -310,6 +310,10 @@ export const Editable = (props: EditableProps) => { } } + if (!native) { + event.preventDefault() + } + // COMPAT: For the deleting forward/backward input types we don't want // to change the selection because it is the range that will be deleted, // and those commands determine that for themselves. @@ -424,7 +428,7 @@ export const Editable = (props: EditableProps) => { // Potentially expand to single character deletes, as well. if (native) { asNative(editor, () => Editor.insertText(editor, data), { - onFlushed: () => (native = false), + onFlushed: () => event.preventDefault(), }) } else { Editor.insertText(editor, data) @@ -434,10 +438,6 @@ export const Editable = (props: EditableProps) => { break } } - - if (!native) { - event.preventDefault() - } } }, [readOnly, propsOnDOMBeforeInput]