AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
867 stars 180 forks source link

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

Open Zealth57 opened 4 years ago

Zealth57 commented 4 years ago

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:

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:

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

elliotcondon commented 4 years ago

Thanks @Zealth57. I'll add this to out to-do and investigate shortly 👍.