AdvancedCustomFields / AdvancedCustomFields/acf

Feature Request: Allow access to inner blocks when building AJAX preview

Open
#476 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

This is similar to https://github.com/AdvancedCustomFields/acf/issues/382#issuecomment-763189897, but instead of needing access to the ancestor context, I need access to the descendants in the inner blocks. This works fine with render_callback on the frontend, but when generating a preview through AJAX $wp_block is null.

To give some details about what I am trying to accomplish, I have a parent ACF block type which has an InnerBlocks that can only contain blocks that are of a child ACF block type. The child ACF block type has a custom field that labels it, which I need to access in order to display in a sort of table of contents which is contained in the parent ACF block type.

This works fine when rendered on the frontend, but when editing I encounter the following issues:

  1. If I change the label in one of the child ACF blocks, the child ACF block preview is updated, but the parent ACF block is not. If the parent ACF block type could be configured to update its preview whenever any of its inner blocks are updated, that could possibly address this issue.
  2. Working around the preview issue, if I manually update the preview of the parent ACF block, it does not include the inner blocks in the AJAX request, so $wp_block is not passed to render_callback as a result. The $wp_block argument on render_callback is what is used to access the inner blocks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the AJAX preview path and the render_callback entry point described in the issue, with attention to how InnerBlocks and $wp_block are handled. Done means a parent ACF block can access its descendant blocks during AJAX previews and can update when an inner block changes; no files or tests are named, so the relevant implementation and test locations must first be identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.