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

Block Bindings: Fix empty custom fields not being editable in bindings #64881

Merged
merged 1 commit into from
Aug 28, 2024
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
Contemplate empty strings and false values
  • Loading branch information
SantosGuillamot committed Aug 28, 2024
commit edbc16d3d1e06d95046b08b4f98613e1d22522af
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
Loading