From 58ed8d640aa94ff56e17d5d727d039d828583441 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Thu, 11 Jun 2020 15:31:09 +0800 Subject: [PATCH] Fix undefined ref when attempting to move group blocks --- .../src/components/use-moving-animation/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 8f250e2421065..d23ff4d5d11bc 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'; + } }, } ); }