Conversation
|
Size Change: +32 B (0%) Total Size: 6.87 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in f63e3f0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22633042336
|
|
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. |
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR! This PR works well for me.
This PR contains a bug fix and I think it can be backported to 7.0, what do you think?
|
Thank you, @t-hamano! I had some second thoughts on this. I'm not 100% sure if I'd like to introduce So I won't try to get this into 7.0. Instead, I'll probably file a PR for the alternative approach (see "Alternatives considered" in the PR description). It might be too late for 7.0 Beta 3 anyway 😅 |
PR: #76200 (WIP) |
What?
Introduce an optional
enumfield in the return value of Block Bindings source'sgetFieldsList()function, and use it to filter source fields by attribute compatibility.Fixes an issue found during discussion on #75543. Follow-up to #76040.
Why?
Prior to this PR, it was possible to bind an
enum-constrained block attribute to an unconstrained Block Bindings source, which can lead to the attribute taking on a value that it's not permitted.How?
By ensuring that
enum-constrained block attributes can only be bound to a Block Bindings source if the latter is also constrained by anenumwhose values are all included in the block attribute's.Testing Instructions
npm run wp-env-test).localhost:8889), activate the "Gutenberg Test Block Bindings" and "Gutenberg Test Server-Side Rendered Block" plugins.emojiattribute to the "Complete Source"'s "Text Field with Enum label" item.Screenshots or screencast
Tradeoffs / Alternatives considered
This introduces
enumsupport for Block Bindings sources as part of a bugfix, where it's used solely for test data. None of the Block Bindings sources included with Gutenberg right now (core/post-meta,core/post-data,core/term-data) currently have any fields to whichenumsupport could be added. While a plausible enhancement, this means that there's currently no demonstrable real-world usage within Core and GB.An alternative -- at least for the time being -- would be to exempt
enum-constrained block attributes from Block Bindings support altogether (instead of introducingenumsupport for Block Bindings source items):