Skip to content

Commit

Permalink
fixed cursor when we triple click on text and type over it ianstormta…
Browse files Browse the repository at this point in the history
…ylor#4862 (ianstormtaylor#4868)

* fixed cursor when we triple click on text and type over it

* fixed

* fixed

* Add changeset

Co-authored-by: Dylan Schiemann <dylan@dojotoolkit.org>
  • Loading branch information
2 people authored and DougReeder committed Apr 3, 2022
1 parent 032c92b commit b127dbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-wasps-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react: patch
---
fixed cursor when triple clicking on text and type over it, fixes #4862
7 changes: 7 additions & 0 deletions packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,13 @@ export const Editable = (props: EditableProps) => {
case 'insertFromYank':
case 'insertReplacementText':
case 'insertText': {
const { selection } = editor
if (selection) {
if (Range.isExpanded(selection)) {
Editor.deleteFragment(editor)
}
}

if (type === 'insertFromComposition') {
// COMPAT: in Safari, `compositionend` is dispatched after the
// `beforeinput` for "insertFromComposition". But if we wait for it
Expand Down

0 comments on commit b127dbb

Please sign in to comment.