Skip to content

Commit

Permalink
fix: caret jump to the start of composition string (ianstormtaylor#5443)
Browse files Browse the repository at this point in the history
* fix:  caret jump to the start of composition str

* chore: add changeset

* chore: edit changeset

---------

Co-authored-by: huangyuning <[email protected]>
  • Loading branch information
OldDream and huangyuning committed Jun 12, 2023
1 parent 5eb589d commit eb7f598
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rare-glasses-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'slate-react': patch
---

fix wrong caret position during composition.
4 changes: 3 additions & 1 deletion packages/slate-react/src/components/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ export const Editable = (props: EditableProps) => {
selection && ReactEditor.toDOMRange(editor, selection)

if (newDomRange) {
if (Range.isBackward(selection!)) {
if (ReactEditor.isComposing(editor)) {
domSelection.collapseToEnd()
} else if (Range.isBackward(selection!)) {
domSelection.setBaseAndExtent(
newDomRange.endContainer,
newDomRange.endOffset,
Expand Down

0 comments on commit eb7f598

Please sign in to comment.