Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Aug 29, 2024
1 parent 09b5a08 commit c6bb728
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions packages/block-editor/src/components/block-inspector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '@wordpress/blocks';
import { PanelBody, __unstableMotion as motion } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useMemo } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -42,29 +41,29 @@ function BlockStylesPanel( { clientId } ) {
}

function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
const { getBlockName, getBlockEditingMode } = useSelect( blockEditorStore );
const { contentClientIds, hasBlockStyles } = useSelect(
const contentClientIds = useSelect(
( select ) => {
const { getClientIdsOfDescendants } = select( blockEditorStore );
const { getBlockStyles } = select( blocksStore );
return {
contentClientIds:
getClientIdsOfDescendants( topLevelLockedBlock ),
hasBlockStyles: !! getBlockStyles(
getBlockName( topLevelLockedBlock )
)?.length,
};
},
[ topLevelLockedBlock, getBlockName ]
);
const eligibleContentClientIds = useMemo(
() =>
contentClientIds.filter(
const {
getClientIdsOfDescendants,
getBlockName,
getBlockEditingMode,
} = select( blockEditorStore );
return getClientIdsOfDescendants( topLevelLockedBlock ).filter(
( clientId ) =>
getBlockName( clientId ) !== 'core/list-item' &&
getBlockEditingMode( clientId ) === 'contentOnly'
),
[ contentClientIds, getBlockName, getBlockEditingMode ]
);
},
[ topLevelLockedBlock ]
);
const hasBlockStyles = useSelect(
( select ) => {
const { getBlockName } = select( blockEditorStore );
const { getBlockStyles } = select( blocksStore );
return !! getBlockStyles( getBlockName( topLevelLockedBlock ) )
?.length;
},
[ topLevelLockedBlock ]
);
const blockInformation = useBlockDisplayInformation( topLevelLockedBlock );
return (
Expand All @@ -78,11 +77,9 @@ function BlockInspectorLockedBlocks( { topLevelLockedBlock } ) {
{ hasBlockStyles && (
<BlockStylesPanel clientId={ topLevelLockedBlock } />
) }
{ eligibleContentClientIds.length > 0 && (
{ contentClientIds.length > 0 && (
<PanelBody title={ __( 'Content' ) }>
<BlockQuickNavigation
clientIds={ eligibleContentClientIds }
/>
<BlockQuickNavigation clientIds={ contentClientIds } />
</PanelBody>
) }
</div>
Expand Down

0 comments on commit c6bb728

Please sign in to comment.