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 committed Sep 3, 2024
1 parent 1f1ed94 commit 6edcde7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/block-editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function PrivateBlockToolbar( {
showParentSelector,
isUsingBindings,
canRemove,
selectedHasTemplateLock,
} = useSelect( ( select ) => {
const {
getBlockName,
Expand Down Expand Up @@ -100,8 +101,10 @@ export function PrivateBlockToolbar( {
( clientId ) =>
!! getBlockAttributes( clientId )?.metadata?.bindings
);
// @TODO If a selected block is locked, we should not show the BlockGroupToolbar.

// 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 +126,7 @@ export function PrivateBlockToolbar( {
_isDefaultEditingMode,
isUsingBindings: _isUsingBindings,
canRemove: canRemoveBlock( selectedBlockClientId ),
selectedHasTemplateLock: _hasTemplateLock,
};
}, [] );

Expand Down Expand Up @@ -208,9 +212,9 @@ export function PrivateBlockToolbar( {
{ ! isMultiToolbar && canRemove && (
<Shuffle clientId={ blockClientId } />
) }
{ shouldShowVisualToolbar && isMultiToolbar && (
<BlockGroupToolbar />
) }
{ ! selectedHasTemplateLock &&
shouldShowVisualToolbar &&
isMultiToolbar && <BlockGroupToolbar /> }
{ shouldShowVisualToolbar && (
<>
<BlockControls.Slot
Expand Down

0 comments on commit 6edcde7

Please sign in to comment.