From 717bbe8966962ad3c72687794c9fe8e7f91061f0 Mon Sep 17 00:00:00 2001 From: Ricardo Artemio Morales Date: Tue, 5 Mar 2024 21:03:23 -0500 Subject: [PATCH] Display parent selector when focused on pattern override --- .../src/components/block-toolbar/index.js | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/block-toolbar/index.js b/packages/block-editor/src/components/block-toolbar/index.js index e566096d54f26..4775f89051f66 100644 --- a/packages/block-editor/src/components/block-toolbar/index.js +++ b/packages/block-editor/src/components/block-toolbar/index.js @@ -66,6 +66,7 @@ export function PrivateBlockToolbar( { shouldShowVisualToolbar, showParentSelector, isUsingBindings, + isPatternOverride, } = useSelect( ( select ) => { const { getBlockName, @@ -93,8 +94,17 @@ export function PrivateBlockToolbar( { const isVisual = selectedBlockClientIds.every( ( id ) => getBlockMode( id ) === 'visual' ); - const _isUsingBindings = !! getBlockAttributes( selectedBlockClientId ) - ?.metadata?.bindings; + const bindings = getBlockAttributes( selectedBlockClientId )?.metadata + ?.bindings; + const _isUsingBindings = !! bindings; + const _isPatternOverride = _isUsingBindings + ? Object.keys( bindings ).some( + ( bindingKey ) => + bindings[ bindingKey ].source === + 'core/pattern-overrides' + ) + : false; + return { blockClientId: selectedBlockClientId, blockClientIds: selectedBlockClientIds, @@ -112,8 +122,9 @@ export function PrivateBlockToolbar( { true ) && selectedBlockClientIds.length === 1 && - _isDefaultEditingMode, + ( _isDefaultEditingMode || _isPatternOverride ), isUsingBindings: _isUsingBindings, + isPatternOverride: _isPatternOverride, }; }, [] ); @@ -164,7 +175,9 @@ export function PrivateBlockToolbar( {
{ ! isMultiToolbar && isLargeViewport && - isDefaultEditingMode && } + ( isDefaultEditingMode || isPatternOverride ) && ( + + ) } { isUsingBindings && canBindBlock( blockName ) && ( ) }