Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Zealth57 opened this issue Sep 3, 2024 · 4 comments
Open

Comments

@Zealth57
Copy link

Zealth57 commented Sep 3, 2024

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:

  • Add an ACF block to the page
  • Open your Chrome dev tools
  • Change the mode to edit mode
  • Make changes to fields in your block
  • Switch the block to preview mode
  • Note in the Network tab, there are no admin-ajax.php API calls with the query[preview]: true property. The frontend of the block does not update because the preview query isn't ran.
  • Now that you're in the preview mode, edit some more field values for the block. Note that the query for the preview runs as expected and your frontend works.
  • Switch back to edit mode and make changes. Not that now when you switch back and forth from edit -> preview it does run the proper admin-ajax.php to update the block.

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:

  • WordPress Version: 6.6.1
  • PHP Version: 8.2.10
  • ACF Version: ACF Pro 6.3.6
  • Browser: Chrome
@lgladdy
Copy link
Member

lgladdy commented Sep 3, 2024

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
Copy link
Author

Zealth57 commented Sep 3, 2024

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
Copy link
Member

lgladdy commented Sep 3, 2024

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
Copy link
Author

Zealth57 commented Sep 3, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants