-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: Allow custom components block bindings UI #65994
Draft
SantosGuillamot
wants to merge
16
commits into
trunk
Choose a base branch
from
update/allow-custom-components-block-bindings-ui
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Block Bindings: Allow custom components block bindings UI #65994
SantosGuillamot
wants to merge
16
commits into
trunk
from
update/allow-custom-components-block-bindings-ui
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SantosGuillamot
added
[Type] New API
New API to be used by plugin developers or package users.
[Feature] Block bindings
labels
Oct 9, 2024
Size Change: +119 B (+0.01%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What?
In this pull request, I'm exploring how extending the block bindings UI could look like. Introducing a basic UI that can be iterated later. Everything is up for debate, and I am still thinking about the different possibilities. I just made something up to trigger the conversations. I'd love to know more opinions if the path of these APIs is good or it should be discarded.
This is one possibility I was considering, and it basically consists of the following:
getFieldsList
API. I am not convinced about how it works right now, and it is limited to the post meta UI.render
property that lets sources decide what to show in the dropdown.FieldsList
component, which allows sources to reuse the UI used for post meta.getBindingLabel
property. This is used in two places so far, in the Attributes panel and in the Rich Text placeholder when the value is empty. (This was previously relying on thegetFieldsList
API.With those mechanisms, sources should be able to introduce the UI they need in an "easy" way. These are a couple of examples, WooCommerce using the same UI as Post Meta, and a Custom Source using a custom component.
You can find the code examples at the end of this post.
Custom.components.binding.demo.mp4
As you can see, the idea is to include in the dropdown only the sources that have defined a
render
property and, if all of them returnnull
, don't show the dropdown at all.In a follow-up pull request, I plan to explore a "default" UI for sources that don't need anything custom. For example, sources registered in the server.
Why?
Extending the UI has been a common demand of block bindings user, and I believe we need to explore how it could be shaped.
Testing Instructions
This should be covered by e2e tests, which have been updated to these changes.
If you want to test it manually, you can register new sources similar to the examples shared below.
Code examples
WooCommerce source registration
Custom source registration