AdvancedCustomFields / acf

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

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

Open jayli66 opened 2 years ago

jayli66 commented 2 years ago

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!

lgladdy commented 2 years ago

@jayli66 Hey Jay,

I took a look at this issue as part of our work on the 6.0.0 alphas. I was unable to reproduce this issue. If you remove the mode => 'preview' part, and just keep the data - does that work?

selvinkuik commented 2 years ago

@lgladdy I can confirm ACF Pro still crashes WP6, even if the mode => 'preview' part is removed

lgladdy commented 2 years ago

@selvinkuik Are you able to get a staging site up you can give us access to reproduce this issue? You can email details through to support@advancedcustomfields.com if so, but given we can't reproduce this, we might need to see it in the wild!

If you look in console, is there any more info? How about any PHP errors in your template that might be being output and corrupting the JSON requests to load the preview?