Skip to content

Commit

Permalink
Remove moverDirection prop from BlockSelectionButton. Use selector in…
Browse files Browse the repository at this point in the history
…stead.
  • Loading branch information
talldan committed Jul 1, 2020
1 parent 288e652 commit 1c73a82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ function BlockPopover( {
clientId,
rootClientId,
isValid,
orientation,
isEmptyDefaultBlock,
capturingClientId,
} ) {
Expand Down Expand Up @@ -195,7 +194,6 @@ function BlockPopover( {
<BlockSelectionButton
clientId={ clientId }
rootClientId={ rootClientId }
moverDirection={ orientation }
/>
) }
{ showEmptyBlockSideInserter && (
Expand All @@ -219,7 +217,6 @@ function wrapperSelector( select ) {
getBlockRootClientId,
__unstableGetBlockWithoutInnerBlocks,
getBlockParents,
getBlockListSettings,
__experimentalGetBlockListSettingsForBlocks,
} = select( 'core/block-editor' );

Expand All @@ -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(
Expand Down Expand Up @@ -262,7 +257,6 @@ function wrapperSelector( select ) {
rootClientId: getBlockRootClientId( clientId ),
name,
isValid,
orientation,
isEmptyDefaultBlock:
name && isUnmodifiedDefaultBlock( { name, attributes } ),
capturingClientId,
Expand All @@ -281,7 +275,6 @@ export default function WrappedBlockPopover() {
rootClientId,
name,
isValid,
orientation,
isEmptyDefaultBlock,
capturingClientId,
} = selected;
Expand All @@ -295,7 +288,6 @@ export default function WrappedBlockPopover() {
clientId={ clientId }
rootClientId={ rootClientId }
isValid={ isValid }
orientation={ orientation }
isEmptyDefaultBlock={ isEmptyDefaultBlock }
capturingClientId={ capturingClientId }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand All @@ -77,7 +79,7 @@ function BlockSelectionButton( {
blockType,
attributes,
index + 1,
moverDirection
orientation
);

const classNames = classnames(
Expand Down

0 comments on commit 1c73a82

Please sign in to comment.