Block Bindings: Deduplicate compatible data computation code#72099
Block Bindings: Deduplicate compatible data computation code#72099ockham wants to merge 5 commits into
Conversation
|
Size Change: -88 B (0%) Total Size: 1.96 MB
ℹ️ View Unchanged
|
|
Turns out the last commit (eb516a8) changes the behavior a bit, causing e2e tests to fail:
The test is "Registered sources › Source compatibility filtering › should show compatible sources enabled and incompatible sources disabled". In the screenshot, the "Modal Source" is supposed to show up as disabled, but it's not. |
|
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. |
|
Closing as stale. Some related work was done in #72974. |

What?
In the client-side Block Bindings code, de-duplicate the logic that computes which of a source's data items are compatible with its attribute type.
See #71542 (comment).
Why?
To avoid redundant computations and code.
How?
This logic existed in
BlockBindingsPanel'useSelect, to compute a boolean calledhasCompatibleData. However, the filtereddataitself was discarded. It was then re-computed inBlockBindingsPanelMenuContent.This PR changes the code such that
source.datais set to the filtered data, which allows us avoiding recomputing it later.Furthermore, we de-duplicate some logic that's shared between the
editorUIand (legacy)getFieldsListbranches.Testing Instructions
Verify that block bindings still work as before.
Specifically, in a test setting with no custom block bindings sources, verify that:
contentattribute can be selected, but not bound to any source;datatimeattribute can be selected, and bound to the Post Data source's "Publish Date" and "Modified Date" items.In a test setting with custom sources (e.g. the "Gutenberg Test Block Bindings" plugin included with e2e tests), try connecting the Paragraph block's
contentattribute to various of the provided source data items.