-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
WordPress 5.0 beta 1 - Javascript error for enqueued custom blocks #11069
Comments
@bfintal Experiencing the same issue with several custom blocks i've created. Can you go into detail on how you includes them as "dependencies upon enqueuing the custom blocks"? |
@dimensionmedia When you enqueue the JS script that registers the custom blocks, just add
|
@dennyf thank you. it's been so long since i've seen that part of my code, I was drawing a blank. I confirmed that I'm no longer getting the JS errors and assume for now this is an accepted solution but will continue to monitor. |
Similarly, styles which are enqueued via wp_enqueue_style(
'my-custom-style-css',
plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ),
array()
); |
… in Gutenberg-in-5.0-beta2 WordPress/gutenberg#11069
Confirming that this also happens in WordPress 5.0-beta2-43845, and that (in my plugin's case) adding |
Noting that bugs that happen in WordPress 5.0 and that do not happen for the Gutenberg plugin should be reported in https://core.trac.wordpress.org/ I wanted to help test before moving the issue but I was unable to reproduce the problem and wanted to check in with you. First, I tested by installing and activating Stackable – Ultimate Gutenberg Blocks 1.4 on WordPress 5.0-beta3-43865 and opening a post for editing and I did not see any errors. I did noticed that the 1.4 changelog mentions fixing invalid script and style dependencies though. Next, I installed and activated Super Cool Ad Inserter Plugin 0.2 on WordPress 5.0-beta3-43865 and manually created an add as a widget and I was able to see the ad display on a test post and did not see any errors in the browser console. @bfintal @benlk since it appears you were able to address the problems, can this issue be closed? |
@designsimply I believe so; this issue is caused by plugin developers not declaring dependencies where Gutenberg-as-plugin had enqueued those dependencies by default. |
Cheers @benlk and thanks for the quick reply! |
Cross-referencing another similar report from WP 5.0 in case it's helpful to someone else later! https://core.trac.wordpress.org/ticket/45219 |
@designsimply @benlk Thanks! Yup I've addressed the problem. However, I think this might mean that the handbook should have more notes regarding dependencies https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/ |
Previously Gutenberg Plugin added these dependencies, related to: https://core.trac.wordpress.org/ticket/45219 and WordPress#11069
Issue #11069 highlighted that the required dependencies should be called out more in the documentation. This PR adds a line adding additional information on including.
Issue #11069 highlighted that the required dependencies should be called out more in the documentation. This PR adds a line adding additional information on including.
Block script loaded before WP core scripts, preventing functionality. See WordPress/gutenberg#11069
Describe the bug
I have a custom block that uses objects from
wp.components
andwp.editor
likeRangeControl
andInspectorControls
. I'm getting errors in 5.0 beta 1 in the editor such as this:Checking the console, it's clear that
wp.components
andwp.editor
are both present. But it's like my custom blocks are ran first before the dependencies.There's no error if the Gutenberg plugin 4.1 is used instead.
The fix for beta 1 that I tried is to include
wp-components
andwp-editor
as dependencies upon enqueuing the custom blocks. Doing that seems to get rid of the error, but again, the error isn't present outside 5.0 beta 1To Reproduce
Steps to reproduce the behavior:
Expected behavior
No errors
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: