Skip to content

Commit

Permalink
Fix post-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 committed Jun 7, 2024
1 parent 744a165 commit d7cc674
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/block-editor/src/components/block-toolbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function PrivateBlockToolbar( {
shouldShowVisualToolbar,
showParentSelector,
isUsingBindings,
hasPatternOverrides,
isNotInPatternOverridesContext,
} = useSelect( ( select ) => {
const {
getBlockName,
Expand Down Expand Up @@ -96,13 +96,19 @@ export function PrivateBlockToolbar( {
const isVisual = selectedBlockClientIds.every(
( id ) => getBlockMode( id ) === 'visual'
);
const _isUsingBindings = !! getBlockAttributes( selectedBlockClientId )
?.metadata?.bindings;
const bindings = getBlockAttributes( selectedBlockClientId )?.metadata
?.bindings;
const parentPatternClientId = getBlockParentsByBlockName(
selectedBlockClientId,
'core/block',
true
)[ 0 ];
const _isNotInPatternOverridesContext =
!! bindings &&
Object.values( bindings ).some(
( binding ) => binding.source === 'core/pattern-overrides'
) &&
! parentPatternClientId;
return {
blockClientId: selectedBlockClientId,
blockClientIds: selectedBlockClientIds,
Expand All @@ -122,8 +128,8 @@ export function PrivateBlockToolbar( {
) &&
selectedBlockClientIds.length === 1 &&
_isDefaultEditingMode,
isUsingBindings: _isUsingBindings,
hasPatternOverrides: !! parentPatternClientId,
isUsingBindings: !! bindings,
isNotInPatternOverridesContext: _isNotInPatternOverridesContext,
};
}, [] );

Expand Down Expand Up @@ -176,7 +182,8 @@ export function PrivateBlockToolbar( {
isLargeViewport &&
isDefaultEditingMode && <BlockParentSelector /> }
{ isUsingBindings &&
hasPatternOverrides &&
// Don't show the indicator if the block connected to pattern overrides but not inside a pattern instance.
! isNotInPatternOverridesContext &&
canBindBlock( blockName ) && (
<BlockBindingsIndicator clientIds={ blockClientIds } />
) }
Expand Down

0 comments on commit d7cc674

Please sign in to comment.