From 3827d018aab6198a7dc227f3e53397527d9b56ae Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 4 Jun 2021 10:50:18 +0100 Subject: [PATCH 1/3] Fix alligned blocks --- packages/block-editor/src/components/block-list/block.js | 1 + .../src/components/block-list/use-block-props/index.js | 6 ++++-- packages/block-editor/src/utils/dom.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block.js b/packages/block-editor/src/components/block-list/block.js index 0923dcb99adcc0..d06c286e430f50 100644 --- a/packages/block-editor/src/components/block-list/block.js +++ b/packages/block-editor/src/components/block-list/block.js @@ -161,6 +161,7 @@ function BlockListBlock( { clientId, className, wrapperProps: omit( wrapperProps, [ 'data-align' ] ), + isAligned, }; const memoizedValue = useMemo( () => value, Object.values( value ) ); diff --git a/packages/block-editor/src/components/block-list/use-block-props/index.js b/packages/block-editor/src/components/block-list/use-block-props/index.js index bbffe084d575c7..4c4c5a6612ad9e 100644 --- a/packages/block-editor/src/components/block-list/use-block-props/index.js +++ b/packages/block-editor/src/components/block-list/use-block-props/index.js @@ -58,7 +58,7 @@ const BLOCK_ANIMATION_THRESHOLD = 200; * @return {Object} Props to pass to the element to mark as a block. */ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) { - const { clientId, className, wrapperProps = {} } = useContext( + const { clientId, className, wrapperProps = {}, isAligned } = useContext( BlockListBlockContext ); const { @@ -141,7 +141,9 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) { 'data-title': blockTitle, className: classnames( // The wp-block className is important for editor styles. - 'wp-block block-editor-block-list__block', + classnames( 'block-editor-block-list__block', { + 'wp-block': ! isAligned, + } ), className, props.className, wrapperProps.className, diff --git a/packages/block-editor/src/utils/dom.js b/packages/block-editor/src/utils/dom.js index 3a6db1685aebb1..4e8e03d54bc358 100644 --- a/packages/block-editor/src/utils/dom.js +++ b/packages/block-editor/src/utils/dom.js @@ -1,6 +1,6 @@ // Consider the block appender to be a child block of its own, which also has // this class. -const BLOCK_SELECTOR = '.wp-block'; +const BLOCK_SELECTOR = '.block-editor-block-list__block'; /** * Returns true if two elements are contained within the same block. From 1fe59876f158801ce96e38542fdf730aeb316fe6 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Fri, 4 Jun 2021 11:11:16 +0100 Subject: [PATCH 2/3] Remove comment --- packages/block-editor/src/utils/dom.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/block-editor/src/utils/dom.js b/packages/block-editor/src/utils/dom.js index 4e8e03d54bc358..4416f8eb4861e8 100644 --- a/packages/block-editor/src/utils/dom.js +++ b/packages/block-editor/src/utils/dom.js @@ -1,5 +1,3 @@ -// Consider the block appender to be a child block of its own, which also has -// this class. const BLOCK_SELECTOR = '.block-editor-block-list__block'; /** From 8bb9a8d31925800410de5f2bec1c0f858d929eb8 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 7 Jun 2021 09:12:02 +0100 Subject: [PATCH 3/3] Fix navigation end2end test failure --- packages/block-library/src/navigation/edit.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/block-library/src/navigation/edit.js b/packages/block-library/src/navigation/edit.js index 0796971e8f9a1a..d4b6cd57b497b5 100644 --- a/packages/block-library/src/navigation/edit.js +++ b/packages/block-library/src/navigation/edit.js @@ -197,10 +197,15 @@ export default compose( [ const selectedBlockHasDescendants = !! getClientIdsOfDescendants( [ selectedBlockId, ] )?.length; + return { isImmediateParentOfSelectedBlock, selectedBlockHasDescendants, hasExistingNavItems: !! innerBlocks.length, + + // This prop is already available but computing it here ensures it's + // fresh compared to isImmediateParentOfSelectedBlock + isSelected: selectedBlockId === clientId, }; } ), withDispatch( ( dispatch, { clientId } ) => {