Skip to content

Commit

Permalink
Filter pattern overrides source in bindings panel (#62015)
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot authored May 29, 2024
1 parent 7fbb0e2 commit 09c1a51
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,40 @@ export const BlockBindingsPanel = ( { metadata } ) => {
return null;
}

// Don't show the bindings connected to pattern overrides in the inspectors panel.
// TODO: Explore if this should be abstracted to let other sources decide.
const filteredBindings = { ...bindings };
Object.keys( filteredBindings ).forEach( ( key ) => {
if ( filteredBindings[ key ].source === 'core/pattern-overrides' ) {
delete filteredBindings[ key ];
}
} );

if ( Object.keys( filteredBindings ).length === 0 ) {
return null;
}

return (
<InspectorControls>
<PanelBody
title={ __( 'Bindings' ) }
className="components-panel__block-bindings-panel"
>
<ItemGroup isBordered isSeparated size="large">
{ Object.keys( bindings ).map( ( key ) => {
{ Object.keys( filteredBindings ).map( ( key ) => {
return (
<Item key={ key }>
<HStack>
<span>{ key }</span>
<span className="components-item__block-bindings-source">
{ sources[ bindings[ key ].source ]
? sources[ bindings[ key ].source ]
.label
: bindings[ key ].source }
{ sources[
filteredBindings[ key ].source
]
? sources[
filteredBindings[ key ]
.source
].label
: filteredBindings[ key ].source }
</span>
</HStack>
</Item>
Expand Down

0 comments on commit 09c1a51

Please sign in to comment.