mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-20 13:22:04 +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:
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,
|
||||
// so enabled only if the selection has been collapsed.
|
||||
if (
|
||||
!editor.selection ||
|
||||
(editor.selection && Range.isCollapsed(editor.selection))
|
||||
domRange.getBoundingClientRect &&
|
||||
(!editor.selection ||
|
||||
(editor.selection && Range.isCollapsed(editor.selection)))
|
||||
) {
|
||||
const leafEl = domRange.startContainer.parentElement!
|
||||
leafEl.getBoundingClientRect = domRange.getBoundingClientRect.bind(domRange)
|
||||
|
Loading…
x
Reference in New Issue
Block a user