AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
823 stars 168 forks source link

$content block variable, is not reactive on preview editor #882

Closed dodo-sofranko closed 7 months ago

dodo-sofranko commented 7 months ago

Describe the bug Inside $content I can go throught inner blocks (for example to know count of used blocks, if I would like to change css with other count) problem is that on preview editor, if I will add some another block, $content contain blocks loaded on beginning, it will not update

Version Information:

lgladdy commented 7 months ago

Hey there,

I don't think this is a bug - the $content parameter is essentially read-only. Blocks run completely isolated from the rest of the page, and don't support modifying anything outside of the block. ACF Block rendering is always isolated per callback or template, so won't have any impact modifying outside of your PHP template.

Unless you mean that if you make changes in the block editor itself (say for example, adding a new InnerBlock via the block editor) it doesn't automatically trigger a refresh of the parent block with the new $content?

dodo-sofranko commented 7 months ago

Hi @lgladdy thanks for response.

"Unless you mean that if you make changes..." Yes I mean that I would like to know count of innerBlocks, that I can change grid with another count and so. But $content is not automatically refreshing.

lgladdy commented 7 months ago

Hey @dodo-sofranko,

Thanks for confirming. This currently isn't supported, but it's also not a bug so I'm going to go ahead and close this report. We could definitely investigate making this an opt in feature though, but it wouldn't be a default because the performance implications of reloading the parent block whenever any child block changes anything would be significant.

We have a feedback board where you can request new features and others can upvote them which our product team will use to plan the development roadmap.

Thanks again!