AdvancedCustomFields / AdvancedCustomFields/acf

ACF block preview: acf_register_block_type > 'example' array crash editor in WordPress 5.9.3

Open
#646 3 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

I use ACF block and add block preview box (the small floating preview box when mouseover block name in "Toggle block inserter" dialog). I use the code in the "Adding block previews" section in this doc:

https://www.advancedcustomfields.com/resources/acf_register_block_type/

Everything worked fine in WordPress 5.8. After upgrade WordPress to 5.9.3, the editor crashes when mouseover block name in "Toggle block inserter" dialog:


"The editor has encountered an unexpected error."

TypeError: b is not iterable
at /wp-includes/js/dist/block-editor.min.js?ver=54657317be78fb1c246c72b38dc2ed0e:7:34730
at Object.wh [as useMemo] (/wp-includes/js/dist/vendor/react-dom.min.js?ver=17.0.1:109:150)


I found that if I remove 'example' array inside acf_register_block_type, it won't crash. But this way block preview can't work.

'example' => array( 'attributes' => array( 'mode' => 'preview', 'data' => array( 'is_example' => true ) ) )

I'm using the latest ACF Pro Version 5.12.2

Please help if there's any solution to fix it. Thanks a ton!

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

Start with the “Adding block previews” example in the acf_register_block_type documentation and reproduce the crash in the WordPress 5.9.3 block inserter using ACF Pro 5.12.2. Investigate the interaction between the example attributes and the reported block-editor.min.js error; done means the inserter opens without an error and the block preview still appears.

Written by the indexing model from the issue text.

Assessment

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