1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-01-18 05:59:13 +01:00

Revert "Do NOT use exact match when updating dom selection" (#4627)

* Revert "Do NOT use exact match when updating dom selection"

The change to `exactMatch: false` in https://github.com/ianstormtaylor/slate/pull/4304
was intended to fix https://github.com/ianstormtaylor/slate/issues/4293,
a bug where "backwards typing" happened in nested editors.

But this change has introduced at least two new bugs:

- https://github.com/ianstormtaylor/slate/issues/4601
- https://github.com/ianstormtaylor/slate/issues/4626

These are (IMO) worse than the original "backwards typing" bug.

From discussion in https://github.com/ianstormtaylor/slate/pull/4304,
the true underlying bug is in ReactEditor.toSlateRange. I'll attempt to
fix this underlying bug instead.

* changeset
This commit is contained in:
Jim Fisher 2021-10-25 16:43:06 +01:00 committed by GitHub
parent 381f91b1dd
commit ec01e75fff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fixed issues where cursor jumps to wrong location

View File

@ -184,7 +184,7 @@ export const Editable = (props: EditableProps) => {
// If the DOM selection is in the editor and the editor selection is already correct, we're done.
if (hasDomSelection && hasDomSelectionInEditor && selection) {
const slateRange = ReactEditor.toSlateRange(editor, domSelection, {
exactMatch: false,
exactMatch: true,
// domSelection is not necessarily a valid Slate range
// (e.g. when clicking on contentEditable:false element)