From 0124a9f38d9c5d8e4890c1e12e65891c62646584 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Wed, 8 Jul 2020 17:24:48 +0800 Subject: [PATCH] Fix an issue where dragging while the page has no scrollbar results in a console error (#23666) --- .../src/components/block-draggable/use-scroll-when-dragging.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/block-editor/src/components/block-draggable/use-scroll-when-dragging.js b/packages/block-editor/src/components/block-draggable/use-scroll-when-dragging.js index e7f869b2d3b0a..aa66c27503cf9 100644 --- a/packages/block-editor/src/components/block-draggable/use-scroll-when-dragging.js +++ b/packages/block-editor/src/components/block-draggable/use-scroll-when-dragging.js @@ -55,6 +55,9 @@ export default function useScrollWhenDragging() { }, [] ); const scrollOnDragOver = useCallback( ( event ) => { + if ( ! scrollParentY.current ) { + return; + } const scrollParentHeight = scrollParentY.current.offsetHeight; const offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop;