Skip to content

Commit

Permalink
Display parent selector when focused on pattern override
Browse files Browse the repository at this point in the history
  • Loading branch information
artemiomorales committed Mar 6, 2024
1 parent 1778ccd commit 717bbe8
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 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( {
shouldShowVisualToolbar,
showParentSelector,
isUsingBindings,
isPatternOverride,
} = useSelect( ( select ) => {
const {
getBlockName,
Expand Down Expand Up @@ -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,
Expand All @@ -112,8 +122,9 @@ export function PrivateBlockToolbar( {
true
) &&
selectedBlockClientIds.length === 1 &&
_isDefaultEditingMode,
( _isDefaultEditingMode || _isPatternOverride ),
isUsingBindings: _isUsingBindings,
isPatternOverride: _isPatternOverride,
};
}, [] );

Expand Down Expand Up @@ -164,7 +175,9 @@ export function PrivateBlockToolbar( {
<div ref={ toolbarWrapperRef } className={ innerClasses }>
{ ! isMultiToolbar &&
isLargeViewport &&
isDefaultEditingMode && <BlockParentSelector /> }
( isDefaultEditingMode || isPatternOverride ) && (
<BlockParentSelector />
) }
{ isUsingBindings && canBindBlock( blockName ) && (
<BlockBindingsIndicator />
) }
Expand Down

0 comments on commit 717bbe8

Please sign in to comment.