Skip to content

Commit 4b2e400

Browse files
authored
Don't remove selection when hovering over a non-selectable DOM element (ianstormtaylor#4577)
* Don't remove selection when hovering over a non-selectable node Fixes ianstormtaylor#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
1 parent 11ef83b commit 4b2e400

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.changeset/curly-timers-watch.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'slate-react': patch
3+
---
4+
5+
Fixed a bug that removed the selection when hovering over a non-selectable DOM element

packages/slate-react/src/components/editable.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,6 @@ export const Editable = (props: EditableProps) => {
505505
exactMatch: false,
506506
})
507507
Transforms.select(editor, range)
508-
} else {
509-
Transforms.deselect(editor)
510508
}
511509
}
512510
}, 100),

0 commit comments

Comments
 (0)