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

Cached blocks don't respect default alignment #302

Open
thunderdw opened this issue Jan 8, 2025 · 1 comment
Open

Cached blocks don't respect default alignment #302

thunderdw opened this issue Jan 8, 2025 · 1 comment

Comments

@thunderdw
Copy link
Contributor

Default alignment can be added by setting the value of the $align property in the block class:

/**
 * The default block alignment.
 *
 * @var string
 */
public $align = 'full';

This works as expected on uncached blocks. When caching blocks, it then generates block.json that looks something like this:

{
    "name": "acf\/example-block",
    "title": "Exmaple Block",
    "description": "Description here",
    "category": "text",
    "icon": "editor-ul",
    "align": "full",

However, the align key isn't a supported key in block.json. I believe the default should instead be set in the block attributes, like:

{
    "name": "acf\/example-block",
    "title": "Exmaple Block",
    "description": "Description here",
    "category": "text",
    "icon": "editor-ul",
    "attributes": {
        "align": {
            "type": "string",
            "default": "full"
        }
    },

I can submit a PR in the next day or two to address this.

@Log1x
Copy link
Owner

Log1x commented Jan 9, 2025

Good catch! PR very appreciated. Looks like https://www.advancedcustomfields.com/resources/extending-acf-blocks-with-block-supports/ is a decent example for it all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants