diff --git a/packages/block-editor/src/components/use-block-drop-zone/index.js b/packages/block-editor/src/components/use-block-drop-zone/index.js index 529eb199fb76a0..d4acb0aaee2432 100644 --- a/packages/block-editor/src/components/use-block-drop-zone/index.js +++ b/packages/block-editor/src/components/use-block-drop-zone/index.js @@ -148,6 +148,10 @@ export function getDropTargetPosition( } ) => { const rect = getBoundingClientRect(); + if ( ! rect ) { + return; + } + let [ distance, edge ] = getDistanceToNearestEdge( position, rect, @@ -428,10 +432,14 @@ export default function useBlockDropZone( { return { isUnmodifiedDefaultBlock: getIsUnmodifiedDefaultBlock( block ), - getBoundingClientRect: () => - ownerDocument - .getElementById( `block-${ clientId }` ) - .getBoundingClientRect(), + getBoundingClientRect: () => { + const blockElement = ownerDocument.getElementById( + `block-${ clientId }` + ); + return blockElement + ? blockElement.getBoundingClientRect() + : null; + }, blockIndex: getBlockIndex( clientId ), blockOrientation: getBlockListSettings( clientId )?.orientation, diff --git a/packages/block-library/src/post-comments-link/edit.js b/packages/block-library/src/post-comments-link/edit.js index e90734e9740bb3..24a5b9a81e8920 100644 --- a/packages/block-library/src/post-comments-link/edit.js +++ b/packages/block-library/src/post-comments-link/edit.js @@ -60,7 +60,13 @@ function PostCommentsLinkEdit( { context, attributes, setAttributes } ) { ); if ( ! post ) { - return null; + return ( +