Skip to content

Commit

Permalink
Don't show non supported attributes (WordPress#62183)
Browse files Browse the repository at this point in the history
Co-authored-by: SantosGuillamot <[email protected]>
Co-authored-by: cbravobernal <[email protected]>
  • Loading branch information
3 people authored and patil-vipul committed Jun 17, 2024
1 parent 3f81c4d commit ea6cefa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import { useSelect } from '@wordpress/data';
/**
* Internal dependencies
*/
import { canBindAttribute } from '../hooks/use-bindings-attributes';
import { unlock } from '../lock-unlock';
import InspectorControls from '../components/inspector-controls';

export const BlockBindingsPanel = ( { metadata } ) => {
export const BlockBindingsPanel = ( { name, metadata } ) => {
const { bindings } = metadata || {};
const { sources } = useSelect( ( select ) => {
const _sources = unlock(
Expand All @@ -33,11 +34,15 @@ export const BlockBindingsPanel = ( { metadata } ) => {
return null;
}

// Don't show not allowed attributes.
// 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' ) {
if (
! canBindAttribute( name, key ) ||
filteredBindings[ key ].source === 'core/pattern-overrides'
) {
delete filteredBindings[ key ];
}
} );
Expand Down

0 comments on commit ea6cefa

Please sign in to comment.