Skip to content

Commit

Permalink
Contemplate empty strings and false values (#64881)
Browse files Browse the repository at this point in the history
Co-authored-by: SantosGuillamot <santosguillamot@git.wordpress.org>
Co-authored-by: cbravobernal <cbravobernal@git.wordpress.org>
  • Loading branch information
3 people authored Aug 28, 2024
1 parent 9b1af68 commit bee0539
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ export default {
}

// Check that the custom field is not protected and available in the REST API.
const isFieldExposed = !! select( coreDataStore ).getEntityRecord(
// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
const fieldValue = select( coreDataStore ).getEntityRecord(
'postType',
postType,
context?.postId
)?.meta?.[ args.key ];

if ( ! isFieldExposed ) {
if ( fieldValue === undefined ) {
return false;
}

Expand Down

0 comments on commit bee0539

Please sign in to comment.