-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Default attributes for block-support properties don't apply on dynamic blocks #50229
Comments
From what I understand, the default are only usually returned when using an instance of the This looks like the code that sets the I don't really know the code well enough to offer suggestions on how to fix it in a backward compatible way. This code has been untouched for years by the looks of it, but @youknowriad last modified it, so might be able to offer suggestions. |
How do you set defaults in block.json? Do you redeclare the style attribute manually? This issue looks like a symptom of the fact that the block parsing in the server is not done "fully". It's just the grammar parse. Unfortunately, there's no solution for that at the moment as introducing the full HTML parsing is too impactful. I'm not really sure why we made sure the default attributes available when using |
My block.json is in the issue description. I'm setting some attributes directly, and for spacing, I set If it helps, for output my render function is simply: function render( $attributes, $content, $block ) {
$wrapper_attributes = get_block_wrapper_attributes();
return sprintf(
'<div %1$s>%2$s</div>',
$wrapper_attributes,
$content
);
} |
I'm encountering the same issue. See a minimal plugin demonstrating the issue here: https://github.com/dutchigor/wordpress-block-supports-render-callback-test |
I just hit this issue today. I would be keen to see some traction. |
This issue was also reported in this ticket: here. I've been able to reproduce it as well. Any clue/idea how can this be fixed? |
The solution fix can be as I explained here #50229 (comment) Make sure to include the default attributes to the "attributes" that are passed to One potential approach as well would be to update |
I am running in to this as well. If a block's
Some additional discussion about default style attributes in |
I'm building a dynamic block, which supports a handful of the built-in style settings (colors, spacing, etc). I can set defaults in
block.json
that apply in the editor, but when I view the front end, it's like nothing is set.get_block_wrapper_attributes
only returns the block class name, none of the color classes are set, and nostyle
attribute.It appears that the default attributes don't exist in
parsed_block
, which is whatapply_block_supports
uses to render the values in PHP.Editor, appears correct:
Front end, no styles:
An example block.json
This sets a default width, colors, and padding, but none of those are applied.
I think this is the same root issue as #50027, but it affects more than just the alignment.
The text was updated successfully, but these errors were encountered: