AdvancedCustomFields / AdvancedCustomFields/acf

Nested/inner ACF block gets duplicated when the settings are identical (ACF 6)

Open
#709 12 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

Now that we can pass parent settings/attributes to the child blocks via "providesContext": { "acf/fields": "data" }, and "usesContext": [ "acf/fields" ],, it makes it really clean/easy to use some logic to render our inner block based on settings on the parent block.

It seems ACF is hashing/caching the inner blocks based on the inner block settings, so my conditional display is ignored, and consecutive inner blocks are identical when they shouldn't be. If I change one setting in each block, everything renders correctly, but that requires every inner block to have unique settings, which isn't helpful.

An example using my specific use-case... my parent ACF block has settings for a columns arrangement. The value ends up being an array like [ '1/4', '3/4' ]. This is passed to the child blocks, then the first, third, fifth, etc. block uses flex-basis: 25% and the second, fourth, sixth, etc. block uses flex-bases: 75%, all via inline styles/variables. With the block caching, all of the inner blocks use flex-basis: 25% and my layout breaks.

This was first brought up via https://github.com/AdvancedCustomFields/acf/issues/654#issuecomment-1251125792 but moved to a separate issue to keep the discussion focused.

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 reproducing the ACF 6 nested-block case described here, using identical inner-block settings and differing parent-provided acf/fields context. Trace the hashing or caching of inner blocks and verify that consecutive children render with their own context-derived layout values rather than duplicating the first child’s result.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.