Skip to content
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

Open
warudin opened this issue Apr 24, 2023 · 2 comments
Open

Default block alignment class is not in get_block_wrapper_attributes #50027

warudin opened this issue Apr 24, 2023 · 2 comments
Assignees
Labels
Needs Technical Feedback Needs testing from a developer perspective. [Package] Blocks /packages/blocks [Type] Bug An existing feature does not function as intended

Comments

@warudin
Copy link

warudin commented Apr 24, 2023

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.

block.json:
{
	...
	"attributes": {
		"align": {
			"type": "string",
			"default": "full"
		}
		...
	},
	"supports": {
		"html": false,
		"align": [
			"wide",
			"full"
		],
		...
	},
	...
}

Step-by-step reproduction instructions

  1. Configure a block to have a specific alignment (i.e. 'full') by adding it as a default value in attributes.align in block.json;
  2. Configure and create a PHP render template file in block.json;
  3. Use get_block_wrapper_attributes() to output the classes in the wrapper div;
  4. Add the block to the editor and leave the default alignment configured, save the editor;
  5. Check the classes being output in the front-end, the configured alignment will not be in the list that's being returned by get_block_wrapper_attributes().

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.2, Gutenberg 15.6.2, custom template (full site editing boilerplate)

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

@Thelmachido Thelmachido added Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended [Package] Blocks /packages/blocks labels Apr 25, 2023
@ndiego ndiego self-assigned this Apr 25, 2023
@ndiego ndiego added Needs Technical Feedback Needs testing from a developer perspective. and removed Needs Testing Needs further testing to be confirmed. labels Apr 25, 2023
@marcoluzi
Copy link

I got the same problem. Did you find a solution for that @warudin ?

@colorful-tones
Copy link
Member

I would love to see this prioritized for the WordPress 6.5 release. Several issues are related, and it may be worth aggregating into a parent task.

@ndiego @gziolo, do you have any insight on the priorities here, please?

Some related issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Technical Feedback Needs testing from a developer perspective. [Package] Blocks /packages/blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants