AdvancedCustomFields / AdvancedCustomFields/acf

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

Open
#926 4 comments 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

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

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

Reproduce the issue in the WordPress editor with an ACF block, using Chrome DevTools Network to compare the first edit-to-preview transition with later transitions. Trace the block preview request and confirm that the first switch sends admin-ajax.php with query[preview]: true and refreshes the block output with current field values.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.