Support

Account

Home Forums Gutenberg WP 6.8 Gutenberg blocks won’t register

Solved

WP 6.8 Gutenberg blocks won’t register

  • Hi,

    I’m just testing the WP 6.8 update and noticed the following error:

    
    acf-pro-blocks.min.js?lfr=Ni40LjAuMQ%3D%3D:1 Uncaught TypeError: Cannot read properties of undefined (reading 'attributes')
        at E (acf-pro-blocks.min.js?lfr=Ni40LjAuMQ%3D%3D:1:25129)
        at Array.map (<anonymous>)
        at acf-pro-blocks.min.js?lfr=Ni40LjAuMQ%3D%3D:1:40591
        at o (acf.min.js?lfr=Ni40LjAuMQ%3D%3D:1:1403)
        at Object.doAction (acf.min.js?lfr=Ni40LjAuMQ%3D%3D:1:573)
        at n.doAction (acf.min.js?lfr=Ni40LjAuMQ%3D%3D:1:14776)
        at post-new.php?post_type=page:2472:5
    

    This is coming from this bit of code:

    
    const u = wp.blocks.registerBlockType(t.name, t);
    return u.attributes.anchor && (u.attributes.anchor = {
      type: "string"
    }),
    

    registerBlockType has a return type of

    WPBlockType | undefined: The block, if it has been successfully registered; otherwise undefined

    Seems like something changed in 6.8 making the block registration fail in JS.
    None of my custom blocks are registered after the update. I’m using the latest ACF PRO version (6.4)

  • Yes, I’ve got the same error!
    This happens on ACF blocks where the (core) anchor attribute is not even set?
    Downgrading to WordPress 6.7.2 is the only way to fix it.

  • This is unrelated to the anchor attribute itself. The registerBlockType function/method fails and returns undefined. After that, accessing attributes throws an error because it’s undefined. Without a deep dive my guess is creating the block structure in JS is not correct anymore.

  • Here’s what’s working for me so far:

    1. Update acf-composer to 3.4.3+ – Fixes the “no support for this block type” issue.
    2. Update ACF to 6.4.0.1+ – Fixes the “called too early” warning

    (h/t to Michiel van Harten via Roots Discord)

    Extra credit:

    ACF blocks with a default alignment will no longer output alignment classes (.alignwide, .alignfull) if $supports['align'] is set to false.

    Previously, this setup would apply the default alignment while hiding the alignment control in the editor UI.

    Now, setting $supports['align'] to false fully disables alignment support, including outputting alignment classes.

    To fix this, update affected blocks to specify at least one alignment option in $supports['align'].

  • AFAICT, the issue is that parent must now be an array or undefined. I was hit by this bug because I passed 'parent' => null to acf_register_block_type().

    https://github.com/WordPress/gutenberg/blob/7506dbbe49367f0641d339473b4416f579bc9376/packages/blocks/src/store/process-block-type.js#L216

  • Thanks @contactstefanfisk-com! I was defaulting to null as well, conditionally adding the parent setting made my blocks show up again.

  • I would like to update acf-composer to 3.4.3+ to fix these no support for this block type issues, however I can’t since I then also need to upgrade Acorn v2 to v3 and that’s not an option for me right now since it’s an older theme.

    Therefore I need to stay on acf-composer 2.1. Is there no other way to fix this? I don’t have $parent defined in any of my acf blocks?

    I can’t upgrade to wordpress 6.8 because of this?
    One of the blocks that doesn’t get registered anymore has the following attributes:

    public $supports = [
    	'align'         => false,
    	'align_text'    => false,
    	'align_content' => false,
    	'anchor'        => false,
    	'mode'          => true,
    	'multiple'      => true,
    	'jsx'           => true
    ];

    And fails on this line in plugins/advanced-custom-fields-pro/assets/build/js/pro/acf-pro-blocks.min.js?ver=6.4.0.1 with error Cannot read properties of undefined (reading 'attributes'):

    return u.attributes.anchor && (u.attributes.anchor = {
    	type: "string"
    }),
Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.