fix(editor): update asset loading for ACF V3 blocks in editor#499
Open
rsanchez-beapi wants to merge 1 commit into
Open
fix(editor): update asset loading for ACF V3 blocks in editor#499rsanchez-beapi wants to merge 1 commit into
rsanchez-beapi wants to merge 1 commit into
Conversation
- Changed the action hook from `enqueue_block_editor_assets` to `enqueue_block_assets` to ensure ACF V3 block previews load correctly within the iframe. - Added comments to clarify the impact of WP 6.3+ on block rendering and lazy loading of images.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 87cbed9. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Depuis WordPress 6.3, le canvas de l’éditeur Gutenberg est isolé dans une iframe (iframe[name="editor-canvas"]). Les blocs ACF V3 (blockVersion: 3) y injectent leurs templates PHP de rendu — y compris le markup lazyload ARI — à chaque rafraîchissement de prévisualisation.
Le script editor.js (qui charge lazySizes) était enregistré via enqueue_block_editor_assets, un hook qui ne cible que la coquille admin, en dehors de l’iframe. Résultat : les images .lazyload des blocs ACF V3 restaient invisibles dans l’éditeur jusqu’à une mutation DOM déclenchant lazySizes.
Ce correctif bascule l’enqueue vers enqueue_block_assets, qui s’exécute dans l’iframe et sur le front, avec un garde is_admin() pour éviter de charger le script côté public.
Changements
Note
Medium Risk
Changes when and where editor JS loads in wp-admin and on the front end; incorrect guarding could enqueue admin editor scripts on the front end or miss them in the iframe.
Overview
Editor script loading is moved from
enqueue_block_editor_assetstoenqueue_block_assetssoeditor.js(including lazySizes) runs inside the WP 6.3+ editor canvas iframe, where ACF Blocks V3 PHP previews and.lazyloadmarkup actually render.admin_editor_script()now returns early when! is_admin()so the same hook does not enqueue that bundle on the public site. Inline comments document why the iframe vs admin-shell split matters for ACF V3 previews.Reviewed by Cursor Bugbot for commit 87cbed9. Bugbot is set up for automated code reviews on this repo. Configure here.