-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Unify logic in getPostMetaFields
function
#65462
Block Bindings: Unify logic in getPostMetaFields
function
#65462
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -35 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code wise this looks nice as there is only one place with the complex logic to collect data and map to the structure needed in other places. I would appreciate some help with testing from @cbravobernal or @artemiomorales.
}, | ||
] ) | ||
); | ||
return getPostMetaFields( registry, context ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So nice to see it like this 👏🏻
Co-authored-by: Greg Ziółkowski <[email protected]>
Co-authored-by: Greg Ziółkowski <[email protected]>
1f1c2b4
to
e4d1a70
Compare
Flaky tests detected in e4d1a70. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11030093440
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been testing main workflows and work as expected.
* Move logic to `getPostMetaFields` function * Update comment to use third-person Co-authored-by: Greg Ziółkowski <[email protected]> * Remove extra space from comment object Co-authored-by: Greg Ziółkowski <[email protected]> * Use props variable --------- Co-authored-by: SantosGuillamot <[email protected]> Co-authored-by: gziolo <[email protected]>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 592d717 |
What?
There is some improvement over how the post meta source is defined as reported in the following comments:
register_meta
in block bindings workflows #65099 (comment)register_meta
in block bindings workflows #65099 (comment)In this pull request, I explored a slightly different approach to the
getPostMetaValues
helper, changing also its name and adding some docs.Why?
Code is tricky to understand and this could help navigating and modifying it.
How?
There are a few aspects to take into account:
null
when the list is empty.value
, the fallback to label or key can't be abstracted because that is only wanted ingetValues
and not in the list of fields shown bygetFieldsList
.type === "wp_template"
because I am not sure if it is necessary. With the new code we try to get the entityRecord values and if not, fall back to how the field has been registered. I could add a check if we consider it safer.Testing Instructions
Everything should keep working as before and e2e tests should pass.