1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-20 21:34:53 +02:00

Don't remove selection when hovering over a non-selectable DOM element (#4577)

* Don't remove selection when hovering over a non-selectable node

Fixes https://github.com/ianstormtaylor/slate/issues/4545

To reproduce the buggy behavior:

1. Create a page that renders a Slate element with a `contentEditable: false` element in it.
2. Start selecting some text with the mouse.
3. During the drag, mouseover the `contentEditable: false` element.

Expected behavior: After doing a drag-to-select with the mouse, from a valid anchor point on mousedown to a valid focus point on mouseup, the selection is set to those anchor and focus points.

Actual behavior: your selection is removed as soon as your mouse hits the `contentEditable: false` element. This is because the current behavior clears the selection if it is momentarily not a valid Slate location.

* Add changeset
This commit is contained in:
Jim Fisher 2021-10-12 01:39:53 +01:00 committed by GitHub
parent 11ef83b47f
commit 4b2e4000d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fixed a bug that removed the selection when hovering over a non-selectable DOM element

View File

@ -505,8 +505,6 @@ export const Editable = (props: EditableProps) => {
exactMatch: false,
})
Transforms.select(editor, range)
} else {
Transforms.deselect(editor)
}
}
}, 100),