diff --git a/packages/block-editor/src/components/use-moving-animation/index.js b/packages/block-editor/src/components/use-moving-animation/index.js index 8f250e24210650..d23ff4d5d11bc6 100644 --- a/packages/block-editor/src/components/use-moving-animation/index.js +++ b/packages/block-editor/src/components/use-moving-animation/index.js @@ -135,11 +135,15 @@ function useMovingAnimation( scrollContainer.current.scrollTop = transform.scrollTop + y; } - ref.current.style.transformOrigin = 'center'; - ref.current.style.transform = - x === 0 && y === 0 ? null : `translate3d(${ x }px,${ y }px,0)`; - ref.current.style.zIndex = - ! isSelected || ( x === 0 && y === 0 ) ? null : '1'; + if ( ref.current ) { + ref.current.style.transformOrigin = 'center'; + ref.current.style.transform = + x === 0 && y === 0 + ? null + : `translate3d(${ x }px,${ y }px,0)`; + ref.current.style.zIndex = + ! isSelected || ( x === 0 && y === 0 ) ? null : '1'; + } }, } ); }