Skip to content

Commit

Permalink
Don't show group toolbar if one or more selected blocks are content l…
Browse files Browse the repository at this point in the history
…ocked.
  • Loading branch information
ramonjd authored and getdave committed Sep 6, 2024
1 parent 80a6026 commit 1b67d9e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/block-editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function PrivateBlockToolbar( {
showParentSelector,
isUsingBindings,
hasParentPattern,
selectedHasTemplateLock,
} = useSelect( ( select ) => {
const {
getBlockName,
Expand All @@ -76,6 +77,7 @@ export function PrivateBlockToolbar( {
getBlockEditingMode,
getBlockAttributes,
getBlockParentsByBlockName,
getTemplateLock,
} = select( blockEditorStore );
const selectedBlockClientIds = getSelectedBlockClientIds();
const selectedBlockClientId = selectedBlockClientIds[ 0 ];
Expand Down Expand Up @@ -103,6 +105,10 @@ export function PrivateBlockToolbar( {
.length > 0
);

// If one or more selected blocks re locked, do not show the BlockGroupToolbar.
const _hasTemplateLock = selectedBlockClientIds.some(
( id ) => getTemplateLock( id ) === 'contentOnly'
);
return {
blockClientId: selectedBlockClientId,
blockClientIds: selectedBlockClientIds,
Expand All @@ -123,6 +129,7 @@ export function PrivateBlockToolbar( {
_isDefaultEditingMode,
isUsingBindings: _isUsingBindings,
hasParentPattern: _hasParentPattern,
selectedHasTemplateLock: _hasTemplateLock,
};
}, [] );

Expand Down Expand Up @@ -205,9 +212,9 @@ export function PrivateBlockToolbar( {
</ToolbarGroup>
</div>
) }
{ shouldShowVisualToolbar && isMultiToolbar && (
<BlockGroupToolbar />
) }
{ ! selectedHasTemplateLock &&
shouldShowVisualToolbar &&
isMultiToolbar && <BlockGroupToolbar /> }
{ shouldShowVisualToolbar && (
<>
<BlockControls.Slot
Expand Down

0 comments on commit 1b67d9e

Please sign in to comment.