diff --git a/packages/block-editor/src/components/block-list/block-wrapper.js b/packages/block-editor/src/components/block-list/block-wrapper.js index 82e4b1fb8ec13b..201276d151514b 100644 --- a/packages/block-editor/src/components/block-list/block-wrapper.js +++ b/packages/block-editor/src/components/block-list/block-wrapper.js @@ -65,7 +65,6 @@ const BlockComponent = forwardRef( 'core/block-editor' ); const fallbackRef = useRef(); - const isAligned = wrapperProps && !! wrapperProps[ 'data-align' ]; wrapper = wrapper || fallbackRef; // Provide the selected node, or the first and last nodes of a multi- @@ -191,7 +190,7 @@ const BlockComponent = forwardRef( mode === 'html' && ! __unstableIsHtml ? '-visual' : ''; const blockElementId = `block-${ clientId }${ htmlSuffix }`; - const blockWrapper = ( + return ( ); - - // For aligned blocks, provide a wrapper element so the block can be - // positioned relative to the block column. - if ( isAligned ) { - const alignmentWrapperProps = { - 'data-align': wrapperProps[ 'data-align' ], - }; - return ( -
- { blockWrapper } -
- ); - } - - return blockWrapper; } ); diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js index f91b5e5223a98d..d7d7c951d31d38 100644 --- a/packages/block-editor/src/components/block-list/block.js +++ b/packages/block-editor/src/components/block-list/block.js @@ -107,6 +107,7 @@ function BlockListBlock( { ? getBlockDefaultClassName( name ) : null; const customClassName = lightBlockWrapper ? attributes.className : null; + const isAligned = wrapperProps && !! wrapperProps[ 'data-align' ]; // The wp-block className is important for editor styles. // Generate the wrapper class names handling the different states of the @@ -116,6 +117,7 @@ function BlockListBlock( { customClassName, 'block-editor-block-list__block', { + 'wp-block': ! isAligned, 'has-warning': ! isValid || !! hasError || isUnregisteredBlock, 'is-selected': isSelected, 'is-highlighted': isHighlighted, @@ -152,6 +154,19 @@ function BlockListBlock( { /> ); + // For aligned blocks, provide a wrapper element so the block can be + // positioned relative to the block column. + if ( isAligned ) { + const alignmentWrapperProps = { + 'data-align': wrapperProps[ 'data-align' ], + }; + blockEdit = ( +
+ { blockEdit } +
+ ); + } + if ( mode !== 'visual' ) { blockEdit =
{ blockEdit }
; }