AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
835 stars 170 forks source link

Edit mode does not run a query to preview when first used on the page #926

Open Zealth57 opened 1 week ago

Zealth57 commented 1 week ago

Describe the bug The first time an ACF block is added to the page and the 'Edit' mode is used, it does not run an admin-ajax call with query[preview]: true when you change from edit mode to preview mode consistently. If you use the preview mode fields then switch back and forth between edit / preview then the admin-ajax call works as expected. This means that when you edit or add content to your ACF fields in edit mode and switch to preview mode, the dynamic block output does not recognize that you've changed the content. It either shows stale or outdated information because the query[preview] doesn't get fired.

To Reproduce Steps to reproduce the behavior:

Expected behavior It seems as though the first time you add a block to the page, you can edit content in the edit mode and switch to the preview mode and your content is never truly updated in the correct way. You can switch back and forth as many times and still won't work. Once you make a change in preview mode, then changing content in edit mode works as you'd expect.

Version Information:

lgladdy commented 1 week ago

Hey! Thanks for the report. It's expected that the preview call shouldn't happen until you switch - but it definitely should when you switch, unless we already have a copy of that block preloaded, which is only possible when the fields are exactly the same.

We're currently working on a significant refactor of all this logic - please stay tuned for a beta of that coming later this year - but we'll be test this as part of that to ensure we've solve this issue.

Thanks! Liam

Zealth57 commented 1 week ago

This is even on a fresh page, only block on the page and nothing particularly special. So didn't copy the block, no other blocks on the page interfering, etc. It does work as expected once I edit a field in 'preview' mode. It's just for some reason this very first time you add it to the page if you don't interact with preview mode fields you only use edit and flip. As you mentioned, I do not expect the preview call to fire until I click the 'preview' icon - but it doesn't do that so the experience is totally broken. Any chance this will get resolved before the refactor? With how narrow the sidebar is with WordPress 6.6 I've been encouraging content editors to use the 'edit' mode now instead of 'preview'. So this will become a huge problem for content editors who are moving into edit mode as their new way to edit things.

lgladdy commented 1 week ago

Hey, Probably not - we're already pretty deep in the refactor, and currently aren't planning another release before then.

We've not seen this issue or heard of this issue before though, so it could be something that requires other conditions to trigger. Does the block in auto mode work?

Zealth57 commented 1 week ago

Ahh this only happens when the mode is set to preview in my block.json. When I change the mode to either auto or edit in my block.json then it fires the correct admin-ajax call to update the template visual output. For now I think I can just change all my modes to edit since content editors can use the UI toggle to get into preview mode if they want it. But like I said, the sidebar width in GB basically makes that unusable for most blocks (as you're aware and I know are already thinking of new ways to do ACF fields in there).