-
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: Enable synced pattern overrides for attributes with role: content
property
#66518
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +51 B (0%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
Flaky tests detected in 3d7c879. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11547720434
|
foreach ( $supported_block_attrs[ $parsed_block['blockName'] ] as $attribute_name ) { | ||
// Retain any non-pattern override bindings that might be present. | ||
$updated_bindings[ $attribute_name ] = isset( $bindings[ $attribute_name ] ) | ||
? $bindings[ $attribute_name ] | ||
: array( 'source' => 'core/pattern-overrides' ); |
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.
This code fires an error for the custom block type. I'm unsure of the best way to handle this, so I just copied the code from core for now to avoid the error while testing.
I also need to make sure you can only enable overrides for custom blocks — I haven't added that handling yet. |
I am not sure about adding a functionality only for custom blocks. I don't know if there is precedence for this. What is the reason for not supporting dynamic core blocks as well? I assume the same problems core blocks have will be faced by custom blocks as well. Additionally, I am a bit concerned about using the |
Hmm, I don't see why we couldn't offer this functionality for certain core dynamic blocks as well. It would depend on the block. I looked at the Search block, for example, and it seems like a good candidate — it doesn't source attributes from the markup, renders all of its HTML based on the For reference, here are the blocks — both dynamic and not — with attributes that have the
Yes as seen above, there are many different kinds of attribute with Perhaps we can start experimenting with agnostic handling for locking the attributes, try migrating a few core blocks over to using that handling, and see what we can learn. |
Great exploration. I like how you are checking how to go extreme and automatically enable support for Block Bindings for all attributes that define |
It appears that customizing inspector controls for synced pattern overrides is currently not possible. I think customizing the UI would be a key part of making this PR a complete feature. We can consider including both of these pieces as part of the iteration for WordPress 6.8. |
There's an experimental PR exploring how to lock attributes, which would be another part of making this PR a complete feature. |
An early experiment exploring enabling synced pattern overrides for blocks that have attributes with the
role: content
property.See #64870
Must be used in conjunction with core PR WordPress/wordpress-develop#7658
Alternative to #66266
What?
It enables synced pattern overrides for custom blocks with the
role: content
property:Why?
We'd like to begin exploring expanding block bindings compatibility.
How?
For the UI, for now it just enables the overrides for any block that has
role: content
. To do: Restrict this to just custom blocks.It also adds some handling on the PHP side to ensure the overrides are rendered.
Testing Instructions
role: content
property wordpress-develop#7658"content":{"Dynamic Icon":{"icon":"square"}}
to the pattern block's JSON, making sure to not overwrite yourref
id. Here's an example:Screenshots or screencast
custom-block-synced-patterns.mp4