Skip to content

Commit

Permalink
Fix deletion of expanded range (#4549)
Browse files Browse the repository at this point in the history
  • Loading branch information
nemanja-tosic committed Sep 26, 2021
1 parent 95e13b0 commit f9c41a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/modern-toes-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': patch
---

Fix deletion of expanded range (#4546)
10 changes: 5 additions & 5 deletions packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -434,10 +438,6 @@ export const Editable = (props: EditableProps) => {
break
}
}

if (!native) {
event.preventDefault()
}
}
},
[readOnly, propsOnDOMBeforeInput]
Expand Down

0 comments on commit f9c41a5

Please sign in to comment.