AdvancedCustomFields / AdvancedCustomFields/acf

Data attribute not always populated, leaves block in a bad state

Open
#383 1 comment 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

If you switch away from a block before the ACF fields have loaded in the sidebar, the data attribute is not saved in the serialized post content, and leaves the block in a permanently bad state.

Steps to reproduce:

  • Add a 1st block to your page
  • Add a 2nd block to your page
  • Before the 2nd block's ACF fields in the sidebar load, click on your 1st block to bring focus to the 1st one

The data for the 2nd block is saved like

<!-- wp:acf/pa-committee-search {"id":"block_5f5bd92b5fab3","name":"acf/pa-committee-search","align":"full","mode":"preview"} /-->

note the absence of a "data" : { } which should have something as I have some default ACF field values. I can change the block field values in the visual mode, but the changes I make don't get reflected on the frontend because "data" is never populated nor updated.

If I go into the code editor, add "data" : {} to the array, save the page, and reload then I can start using the block again fine and it saves my changes.

This can also be reproduced another way which makes the bug a bit less edge case and more important:

  • Set your block to default into Visual mode
  • Enter full screen mode and no sidebar at all
  • Add a block to your page
  • Save your page
  • View your page on the frontend

The block will not show up because the data attribute is not populated again.

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 two editor scenarios described: switching blocks before ACF fields load, and saving a block with no sidebar. Trace where the block is serialized and where its ACF data is restored; done means the saved content includes the data attribute and the block renders and persists field changes on the frontend.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
full-stack
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.