Skip to content

Commit

Permalink
Remove empty sources from fieldsList
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed Jul 29, 2024
1 parent d14d50f commit 2dff252
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ export const BlockBindingsPanel = ( { name, metadata } ) => {
}
}
);
// Remove empty sources.
Object.entries( fieldsList ).forEach( ( [ key, value ] ) => {
if ( ! Object.keys( value ).length ) {
delete fieldsList[ key ];
}
} );

// At this moment, the UI can be locked when there are no fields to connect to.
const readOnly = ! Object.keys( fieldsList ).length;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default {
context?.postId
).meta;

if ( ! metaFields ) {
if ( ! metaFields || ! Object.keys( metaFields ).length ) {
return null;
}

Expand Down

0 comments on commit 2dff252

Please sign in to comment.