Skip to content

Commit

Permalink
Rename selectedHasTemplateLock to hasContentOnlyLocking.
Browse files Browse the repository at this point in the history
In the block-switcher, only hide the drop down if a selected block is content locked.
  • Loading branch information
ramonjd committed Sep 4, 2024
1 parent d89f82f commit c8ec66f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions packages/block-editor/src/components/block-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ const BlockIndicator = ( { icon, showTitle, blockTitle } ) => (

export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => {
const {
selectedHasTemplateLock,
hasContentOnlyLocking,
canRemove,
hasBlockStyles,
icon,
Expand Down Expand Up @@ -255,7 +255,7 @@ export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => {
_isSingleBlockSelected && isReusableBlock( _blocks[ 0 ] ),
isTemplate:
_isSingleBlockSelected && isTemplatePart( _blocks[ 0 ] ),
selectedHasTemplateLock: _hasTemplateLock,
hasContentOnlyLocking: _hasTemplateLock,
};
},
[ clientIds ]
Expand All @@ -265,7 +265,7 @@ export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => {
maximumLength: 35,
} );

if ( invalidBlocks || selectedHasTemplateLock ) {
if ( invalidBlocks ) {
return null;
}

Expand All @@ -274,7 +274,10 @@ export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => {
? blockTitle
: __( 'Multiple blocks selected' );

const hideDropdown = disabled || ( ! hasBlockStyles && ! canRemove );
const hideDropdown =
disabled ||
( ! hasBlockStyles && ! canRemove ) ||
hasContentOnlyLocking;

if ( hideDropdown ) {
return (
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function PrivateBlockToolbar( {
shouldShowVisualToolbar,
showParentSelector,
isUsingBindings,
selectedHasTemplateLock,
hasContentOnlyLocking,
} = useSelect( ( select ) => {
const {
getBlockName,
Expand Down Expand Up @@ -119,7 +119,7 @@ export function PrivateBlockToolbar( {
selectedBlockClientIds.length === 1 &&
_isDefaultEditingMode,
isUsingBindings: _isUsingBindings,
selectedHasTemplateLock: _hasTemplateLock,
hasContentOnlyLocking: _hasTemplateLock,
};
}, [] );

Expand Down Expand Up @@ -202,7 +202,7 @@ export function PrivateBlockToolbar( {
</ToolbarGroup>
</div>
) }
{ ! selectedHasTemplateLock &&
{ ! hasContentOnlyLocking &&
shouldShowVisualToolbar &&
isMultiToolbar && <BlockGroupToolbar /> }
{ shouldShowVisualToolbar && (
Expand Down

0 comments on commit c8ec66f

Please sign in to comment.