Support

Account

Home Forums Backend Issues (wp-admin) Duplicated ACF Blocks in Widgets failing to save/render correctly

Unread

Duplicated ACF Blocks in Widgets failing to save/render correctly

  • ## Issue
    When duplicating an ACF block (registered with acf_register_block_type) data between the blocks can switch place and/or regress. Repeater fields and expander toggles stop working. No javascript error is shown in console.

    ## Environment
    PHP 7.4.21
    WP 5.8.1
    ACF Pro 5.10.2

    ## Reproduce
    1. Create ACF Field Group

    
    acf_add_local_field_group(array(
    	'key' => 'group_614c3a15115de',
    	'title' => 'Test Block',
    	'fields' => array(
    		array(
    			'key' => 'field_614c3c7d9b75e',
    			'label' => 'Test Field',
    			'name' => 'test_field',
    			'type' => 'text',
    			'instructions' => '',
    			'required' => 0,
    			'conditional_logic' => 0,
    			'wrapper' => array(
    				'width' => '',
    				'class' => '',
    				'id' => '',
    			),
    			'default_value' => '',
    			'placeholder' => '',
    			'prepend' => '',
    			'append' => '',
    			'maxlength' => '',
    		),
    	),
    	'location' => array(
    		array(
    			array(
    				'param' => 'block',
    				'operator' => '==',
    				'value' => 'acf/test-block',
    			),
    		),
    	),
    	'menu_order' => 0,
    	'position' => 'acf_after_title',
    	'style' => 'default',
    	'label_placement' => 'top',
    	'instruction_placement' => 'label',
    	'hide_on_screen' => '',
    	'active' => true,
    	'description' => '',
    	'is_acf_component' => 0,
    	'acf_component_defaults' => array(
    		'repeatable' => '0',
    		'min' => '',
    		'max' => '',
    		'layout' => 'block',
    		'button_label' => '',
    		'appearances' => '',
    	),
    ));
    

    2. Register ACF Block

    
    acf_register_block_type(array(
    	'name' => 'test_block',
    	'title' => __('Test Block'),
    	'description' => __('Test Block'),
    	'render_template' => 'template-parts/content_builder-test.php',
    	'category' => 'formatting',
    ));
    

    3. Create template file in render_template location with the contents: <?php the_field('test_field');
    3. Navigate to Widgets wp-admin/widgets.php
    4. Add new ‘Test Block’
    5. Duplicate ‘Test Block’ a few times.
    6. Edit the contents of the fields, toggle between Edit/Preview.

    ## Expected Result
    All fields and admin elements should work as normal.

    ## Actual Result
    The preview does not align with the content, when switching back to edit, the value in the field may have changed too. The ‘Update’ button often is not triggered to an active state. When managing to save, reloading shows the widgets in a different state to when you left it.

    ## Extra
    Copying the contents into a reusable block, editing then copy/pasting back in does not work. (Reusable blocks are not supported in the Widgets interface just yet.)

    ## Work around
    Create all blocks from scratch within the widgets interface.

    Thank you.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.