From 09c1a518db8711c42becc71f0da1903952249026 Mon Sep 17 00:00:00 2001 From: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com> Date: Wed, 29 May 2024 11:14:20 +0200 Subject: [PATCH] Filter pattern overrides source in bindings panel (#62015) --- .../block-editor/src/hooks/block-bindings.js | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/hooks/block-bindings.js b/packages/block-editor/src/hooks/block-bindings.js index 72ac01a099e6d6..5e6a9486fcd66d 100644 --- a/packages/block-editor/src/hooks/block-bindings.js +++ b/packages/block-editor/src/hooks/block-bindings.js @@ -33,6 +33,19 @@ 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 ( { className="components-panel__block-bindings-panel" > - { Object.keys( bindings ).map( ( key ) => { + { Object.keys( filteredBindings ).map( ( key ) => { return ( { key } - { sources[ bindings[ key ].source ] - ? sources[ bindings[ key ].source ] - .label - : bindings[ key ].source } + { sources[ + filteredBindings[ key ].source + ] + ? sources[ + filteredBindings[ key ] + .source + ].label + : filteredBindings[ key ].source }