-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 block alignment class is not in get_block_wrapper_attributes #50027
Comments
I got the same problem. Did you find a solution for that @warudin ? |
I trapped on same situation as @warudin says. However, it may be fixed in upcoming release. In the meantime, I find out a temprary solution. My render.php is like
|
This is exactly the same issue that I run into. I use ACF to be able to use render.php files for rendering my HTML. My block.json contains this: But when I use get_block_wrapper_attributes(), the class alignleft is not added to the classes by default. |
The fix: diff --git a/src/wp-includes/class-wp-block-supports.php b/src/wp-includes/class-wp-block-supports.php
index c90b5e0c54..71d6b49691 100644
--- a/src/wp-includes/class-wp-block-supports.php
+++ b/src/wp-includes/class-wp-block-supports.php
@@ -104,7 +104,7 @@ class WP_Block_Supports {
}
$block_attributes = array_key_exists( 'attrs', self::$block_to_render ) && is_array( self::$block_to_render['attrs'] )
- ? self::$block_to_render['attrs']
+ ? $block_type->prepare_attributes_for_render( self::$block_to_render['attrs'] )
: array();
$output = array(); I will fix the issue in the WordPress core and file a related Trac ticket (if there isn't one already).
|
Fix: WordPress/wordpress-develop#7438 |
It should be resolved after WordPress 6.7 gets released in November. Related commit: WordPress/wordpress-develop@7d0e751. |
I don't think it got resolved in 6.7. At least it's not working for me. |
@odyn, could you share more details about your use case so we could debug what’s happening? |
Ok, sorry. I'm quite a beginner, but here it goes. { In the GUI I DO get the options for the Colors, Typography (Size and Line Height) and Dimension (Padding, Margin and Block Spacing), but not for either textAlign or for align. I may however have a bug somewhere, since I cannot click the block in the editor to select it, but only in the Document Overview. |
In the |
Well, I do have this in index.js: import Edit from './edit'; /**
and this in edit.js: export default function Edit({ attributes, setAttributes }) {
} So I'm guessing yes? |
Can you try the following change? - <div { ...useBlockProps }>
+ <div { ...blockProps }> |
Hm no ... that returns an error: " This block has encountered an error and
cannot be previewed.".
…On Fri, Nov 22, 2024 at 9:42 AM Greg Ziółkowski ***@***.***> wrote:
Can you try the following change?
- <div { ...useBlockProps }>+ <div { ...blockProps }>
—
Reply to this email directly, view it on GitHub
<#50027 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AASXB3CUXDQ2NSNLTPWTA432B3U6JAVCNFSM6AAAAABOIACTBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJTGE4TONJSGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Description
I created a block, the settings are below in the block.json.
The block should have a full width alignment by default (mentioned here in the documentation: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#align)
This works good in the editor. But in my render file, the
get_block_wrapper_attributes()
function is not outputting the align class.The align class is only returned when I configure another block width then the one that’s in the attributes (so ‘none’ or ‘wide’). The default alignment is never returned, even after toggling another one and going back to the default alignment.
Step-by-step reproduction instructions
get_block_wrapper_attributes()
to output the classes in the wrapper div;get_block_wrapper_attributes()
.Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: