mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 04:20:26 +02:00
Check if getBoundingClientRect exist before trying to call bind (#5226)
* Stop trying to call bind on undifined when getBoundingClientRect is not defined. This is happening when testing slate with react testing library * Add changeset
This commit is contained in:
committed by
GitHub
parent
224b7ebba3
commit
0141f68365
5
.changeset/curly-news-cover.md
Normal file
5
.changeset/curly-news-cover.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': minor
|
||||||
|
---
|
||||||
|
|
||||||
|
Check if getBoundingClientRect exist before trying to call bind on it. Makes unit testing experience agains Editable nicer
|
@@ -1691,8 +1691,9 @@ const defaultScrollSelectionIntoView = (
|
|||||||
// This was affecting the selection of multiple blocks and dragging behavior,
|
// This was affecting the selection of multiple blocks and dragging behavior,
|
||||||
// so enabled only if the selection has been collapsed.
|
// so enabled only if the selection has been collapsed.
|
||||||
if (
|
if (
|
||||||
!editor.selection ||
|
domRange.getBoundingClientRect &&
|
||||||
(editor.selection && Range.isCollapsed(editor.selection))
|
(!editor.selection ||
|
||||||
|
(editor.selection && Range.isCollapsed(editor.selection)))
|
||||||
) {
|
) {
|
||||||
const leafEl = domRange.startContainer.parentElement!
|
const leafEl = domRange.startContainer.parentElement!
|
||||||
leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange)
|
leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange)
|
||||||
|
Reference in New Issue
Block a user