Support

Account

Home Forums Bug Reports ACF block and custom style added via wp.blocks.registerBlockStyle

Solving

ACF block and custom style added via wp.blocks.registerBlockStyle

  • Hello,

    There is a bug in the ACF PRO Version 5.8.3 with Gutenberg (WordPress 5.2.2) that wasn’t there in beta (Version 5.8.0-beta4.1).

    When you add styles to the block via wp.blocks.registerBlockStyle, the preview/edit functionality doesn’t work: the edit UI doesn’t load after switching styles and previewing block.

    I’m attaching the gif with bug recording.

    Code registering block:

    			// spoiler popup
    			acf_register_block(
    				array(
    					'name'            => 'ma_spoiler_popup',
    					'title'           => __( 'Toggle Popup' ),
    					'description'     => __( 'A custom block for adventskalender hidden content inside popup' ),
    					'render_callback' => [ 'MA_Editor_Blocks', 'acf_block_render_callback' ],
    					'category'        => 'advents',
    					'icon'            => 'editor-expand',
    					'keywords'        => array( 'popup', 'spoiler', 'accordion' ),
    					'mode'            => 'edit',
    					'supports'        => [
    						'align' => false,
    					],
    				)
    			);

    Render template:

    <?php
    /**
     * Block : Spoiler Popup
     */
    
    $intro       = get_field( 'intro_line' );
    $button_text = ( get_field( 'button_text' ) ) ? get_field( 'button_text' ) : '+';
    $content     = get_field( 'popup_content' );
    $class       = ( isset( $block['className'] ) ) ? $block['className'] : '';
    
    ?>
    <div class="<?php echo esc_attr( $class ); ?>">
    	<p class="popup__intro">
    		<span><?php echo esc_html( $intro ); ?></span>
    		<span class="botton_cls" data-popup-trigger="<?php echo esc_attr( $block['id'] ); ?>"><span class="botton_cls__inner"><?php echo esc_html( $button_text ); ?></span></span>
    	</p>
    	<div class="popup__hidden" data-popup="<?php echo esc_attr( $block['id'] ); ?>">
    		<?php echo do_shortcode( wp_kses_post( $content ) ); ?>
    	</div>
    </div>
  • Breaking bug, still present in 5.8.4
    Any comment as to when we can expect a fix for this?

  • Hi all,

    Elliot here – ACF dev.

    I was made aware of this forum thread via the following GitHub issue: https://github.com/AdvancedCustomFields/acf/issues/246#event-2786440261

    Please join me on GitHub to discuss replicating this issue so I may debug the problem.

    Thanks
    Elliot

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.