From 1c73a8284377bb3b424f491e1f6089d1b4dcc0a4 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Wed, 1 Jul 2020 15:50:19 +0800 Subject: [PATCH] Remove moverDirection prop from BlockSelectionButton. Use selector instead. --- .../components/block-list/block-popover.js | 8 -------- .../block-list/block-selection-button.js | 20 ++++++++++--------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block-popover.js b/packages/block-editor/src/components/block-list/block-popover.js index 8d1fff9e372e63..87ca8ebd55a555 100644 --- a/packages/block-editor/src/components/block-list/block-popover.js +++ b/packages/block-editor/src/components/block-list/block-popover.js @@ -47,7 +47,6 @@ function BlockPopover( { clientId, rootClientId, isValid, - orientation, isEmptyDefaultBlock, capturingClientId, } ) { @@ -195,7 +194,6 @@ function BlockPopover( { ) } { showEmptyBlockSideInserter && ( @@ -219,7 +217,6 @@ function wrapperSelector( select ) { getBlockRootClientId, __unstableGetBlockWithoutInnerBlocks, getBlockParents, - getBlockListSettings, __experimentalGetBlockListSettingsForBlocks, } = select( 'core/block-editor' ); @@ -230,11 +227,9 @@ function wrapperSelector( select ) { return; } - const rootClientId = getBlockRootClientId( clientId ); const { name, attributes = {}, isValid } = __unstableGetBlockWithoutInnerBlocks( clientId ) || {}; const blockParentsClientIds = getBlockParents( clientId ); - const { orientation } = getBlockListSettings( rootClientId ) || {}; // Get Block List Settings for all ancestors of the current Block clientId const ancestorBlockListSettings = __experimentalGetBlockListSettingsForBlocks( @@ -262,7 +257,6 @@ function wrapperSelector( select ) { rootClientId: getBlockRootClientId( clientId ), name, isValid, - orientation, isEmptyDefaultBlock: name && isUnmodifiedDefaultBlock( { name, attributes } ), capturingClientId, @@ -281,7 +275,6 @@ export default function WrappedBlockPopover() { rootClientId, name, isValid, - orientation, isEmptyDefaultBlock, capturingClientId, } = selected; @@ -295,7 +288,6 @@ export default function WrappedBlockPopover() { clientId={ clientId } rootClientId={ rootClientId } isValid={ isValid } - orientation={ orientation } isEmptyDefaultBlock={ isEmptyDefaultBlock } capturingClientId={ capturingClientId } /> diff --git a/packages/block-editor/src/components/block-list/block-selection-button.js b/packages/block-editor/src/components/block-list/block-selection-button.js index 75cfe961690a6a..5e9f9326cacb05 100644 --- a/packages/block-editor/src/components/block-list/block-selection-button.js +++ b/packages/block-editor/src/components/block-list/block-selection-button.js @@ -30,29 +30,31 @@ import BlockTitle from '../block-title'; * * @return {WPComponent} The component to be rendered. */ -function BlockSelectionButton( { - clientId, - rootClientId, - moverDirection, - ...props -} ) { +function BlockSelectionButton( { clientId, rootClientId, ...props } ) { const selected = useSelect( ( select ) => { const { __unstableGetBlockWithoutInnerBlocks, getBlockIndex, hasBlockMovingClientId, + getBlockListSettings, } = select( 'core/block-editor' ); const index = getBlockIndex( clientId, rootClientId ); const { name, attributes } = __unstableGetBlockWithoutInnerBlocks( clientId ); const blockMovingMode = hasBlockMovingClientId(); - return { index, name, attributes, blockMovingMode }; + return { + index, + name, + attributes, + blockMovingMode, + orientation: getBlockListSettings( rootClientId )?.orientation, + }; }, [ clientId, rootClientId ] ); - const { index, name, attributes, blockMovingMode } = selected; + const { index, name, attributes, blockMovingMode, orientation } = selected; const { setNavigationMode, removeBlock } = useDispatch( 'core/block-editor' ); @@ -77,7 +79,7 @@ function BlockSelectionButton( { blockType, attributes, index + 1, - moverDirection + orientation ); const classNames = classnames(