Support

Account

Home Forums Gutenberg ACF Blocks v3 autoInlineEditing stops working when a text field contains inline

Unread

ACF Blocks v3 autoInlineEditing stops working when a text field contains inline

  • Hi,

    I have encountered an issue with automatic inline editing in ACF Blocks v3.

    Environment

    • WordPress 7.0.2
    • ACF PRO 6.8.7
    • Block API version 3
    • ACF block version 3
    • autoInlineEditing enabled

    Example block.json configuration:

    
    
    {
    	"apiVersion": 3,
    	"name": "example/hero",
    	"acf": {
    		"blockVersion": 3,
    		"mode": "preview",
    		"renderTemplate": "render.php",
    		"autoInlineEditing": true
    	}
    }

    Example render template:

    
    
    <?php
    $heading = get_field('heading');
    ?>
    
    <h2>
    	<?php echo wp_kses_post((string) $heading); ?>
    </h2>

    When the field contains plain text, for example:

    Example heading

    ACF correctly identifies the <h2> element and adds the inline-editing attributes. Inline editing works as expected.

    However, when the field value contains inline HTML:

    Example <strong>formatted text<strong>

    inline editing stops working after the block preview is rendered again. The corresponding element no longer receives data-acf-inline-contenteditable, so the field can only be edited through the sidebar or expanded editor.

    Steps to reproduce

    1. Create an ACF Block v3 with autoInlineEditing enabled.
    2. Add an ACF text or textarea field named heading.
    3. Output the field in the render template using wp_kses_post().
    4. Initially set the field value to plain text.
    5. Confirm that inline editing works.
    6. Change the value so that it contains an inline element such as <strong> or <em>.
    7. Allow ACF to render the block preview again.
    8. Try to activate inline editing on the rendered element.

    Expected result&lt

    The original container should remain inline-editable when its field value contains supported inline HTML elements such as <strong> or <em>.

    Actual result

    After the preview is rendered again, ACF no longer identifies the container as belonging to the text field, and the data-acf-inline-contenteditable attributes are missing.

    Current workaround

    Explicitly adding the mapping works:

    
    
    <h2 <?php echo acf_inline_text_editing_attrs('heading'); ?>>
    	<?php echo wp_kses_post((string) get_field('heading')); ?>
    </h2>

    However, this requires manually annotating every field and reduces the usefulness of autoInlineEditing.

    Would it be possible for automatic inline editing to support values containing inline HTML—for example by comparing normalized innerHTML, complete textContent, or otherwise preserving the field-to-element association across preview renders?

    Thank you.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.