Skip to content

Commit

Permalink
Fix: indentation followup (#34173)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasmussen authored Aug 19, 2021
1 parent 1021a4b commit ab1380c
Showing 1 changed file with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,36 @@ import BlockToolbar from '../block-toolbar';
import { store as blockEditorStore } from '../../store';

function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {
const {
blockType,
hasParents,
showParentSelector,
isMultiSelecting,
} = useSelect( ( select ) => {
const {
getBlockName,
getBlockParents,
getSelectedBlockClientIds,
} = select( blockEditorStore );
const { getBlockType } = select( blocksStore );
const selectedBlockClientIds = getSelectedBlockClientIds();
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
const parents = getBlockParents( selectedBlockClientId );
const firstParentClientId = parents[ parents.length - 1 ];
const parentBlockName = getBlockName( firstParentClientId );
const parentBlockType = getBlockType( parentBlockName );
const { blockType, hasParents, showParentSelector } = useSelect(
( select ) => {
const {
getBlockName,
getBlockParents,
getSelectedBlockClientIds,
} = select( blockEditorStore );
const { getBlockType } = select( blocksStore );
const selectedBlockClientIds = getSelectedBlockClientIds();
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
const parents = getBlockParents( selectedBlockClientId );
const firstParentClientId = parents[ parents.length - 1 ];
const parentBlockName = getBlockName( firstParentClientId );
const parentBlockType = getBlockType( parentBlockName );

return {
blockType:
selectedBlockClientId &&
getBlockType( getBlockName( selectedBlockClientId ) ),
hasParents: parents.length,
showParentSelector: hasBlockSupport(
parentBlockType,
'__experimentalParentSelector',
true
),
isMultiSelecting: selectedBlockClientIds.length > 1,
};
}, [] );
return {
blockType:
selectedBlockClientId &&
getBlockType( getBlockName( selectedBlockClientId ) ),
hasParents: parents.length,
showParentSelector:
hasBlockSupport(
parentBlockType,
'__experimentalParentSelector',
true
) && selectedBlockClientIds.length <= 1,
};
},
[]
);

if ( blockType ) {
if ( ! hasBlockSupport( blockType, '__experimentalToolbar', true ) ) {
Expand All @@ -59,7 +57,7 @@ function BlockContextualToolbar( { focusOnMount, isFixed, ...props } ) {

// Shifts the toolbar to make room for the parent block selector.
const classes = classnames( 'block-editor-block-contextual-toolbar', {
'has-parent': hasParents && showParentSelector && ! isMultiSelecting,
'has-parent': hasParents && showParentSelector,
'is-fixed': isFixed,
} );

Expand Down

0 comments on commit ab1380c

Please sign in to comment.