Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show non-existing and not supported attributes in block bindings panel #62183

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading