-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Enqueuing 'wp-editor' script together with wp-edit-widgets or wp-customize-widgets triggers _doing_it_wrong error #67333
Comments
Yep, the lowdown is that there's a namespace clash for It looks like this issue from #65937, as that adds the editor dependency. Possible solutions:
|
Thanks for the context @talldan 🙇🏻 |
Interesting 🤔 It's true that now that those sources are used outside of the editor in places like widgets, maybe we need to move core sources outside of that package. It makes sense conceptually to me. I am not sure which package we should use, and creating a new one seems too much to me. I feel it would make sense to have them in the |
I'd be surprised if those usages of the editor package return anything in the widget editor. 🤔 Maybe it doesn't matter though, the usage seems like it wouldn't prevent the source from working. |
Post Meta source depends on |
For the editor dependency, a solution could be to extract the dependency and instead pass the getters in, e.g.: // editor package
import { createPostMetaSource } from '@wordpress/core-data';
// ...
const postMetaSource = createPostMetaSource( { getCurrentPostType, getEditorSettings } );
registerBindingSource( postMetaSource ); It could even be generalized to a I don't have a strong opinion on the solution though, just offering some options. |
Core-data make network calls through api-fetch but that's fine. edit-widgets also does.
No, that's not the right place for it. The "fields" package is the equivalent of the "block-library" package but for "fields and actions" (it's a library of WP specific fields and actions). My main question is why we need bindings support in the widgets screen? If that support is inevitable, we might have to create a dedicated package for bindings. It's unfortunate thought that a legacy screen is forcing us to do so. |
Also looking at the code of the "post-meta" binding, I think the "editor" dependency is not needed at all:
|
I guess that could be reconsidered as well. The original idea was that bindings could be used wherever blocks are used.
You might be right. I remember having some issues at some point, but I don't see now why that shouldn't work.
I am not sure about this. If a block is connected to post meta, even if the metabox is enabled, shouldn't we show the meta field value (or even the UI to connect fields)? I'll explore how to remove the |
Good point :)
I think if this was done just by principle, we should maybe reconsider given these widgets are kind of legacy. |
I was only confirming what @talldan said, that we can't move registration of Post Meta source to
Now, regarding the existing code. I agree that this fallback is not necessary here:
The code is here: gutenberg/packages/editor/src/bindings/post-meta.js Lines 125 to 127 in 0f6ab5d
It's only necessary for the post editor to detect whether the user enabled legacy metaboxes. So, we could find an alternative approach that calls this code using the key of the store represented as a string if necessary.
Yes, it was exactly that. That's surprising that both widgets screens has these implications regarding |
One thing is that Synced Patterns don't actually work in the widget editors at the moment, so I guess there's no need for pattern overrides bindings. IIRC, this was because the multi entity saving flow was never implemented. It's something that could probably be revisited though—synced patterns can no longer be edited from the block instance. Also wondering if it's common to use post meta with widget areas (and if it's been tested that it works?) Another concern is that without the multi-entity saving, if a binding edits something like a site tagline, then it might not be saveable. |
I've created this pull request to remove the fallback in post meta. I can explore in another pull request legacy metaboxes. Regarding widgets, I'm fine removing client-side bindings support there. I don't think it is a common use case. It was tested a bit, but it doesn't have a proper testing suite. If we agree on that, I'll work on a pull request to remove support. |
I've started this pull request in case we want to remove client-side support in the widgets screen. |
I've merged the PR to remove the client-side registration in the widgets screen. We can always add it back properly in the future if needed. Should this be part of 6.7.2? |
Description
For classic themes with Gutenberg activated, the following
_doing_it_wrong
PHP notice appears when loading the Widgets the editor:The error comes from the
wp_check_widget_editor_deps
check in Core:https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/widgets.php#L2094
In the plugin, it's triggered in client-asset.php
gutenberg/lib/client-assets.php
Line 230 in eadf2dd
I'm not sure how to filter out and load separately here.
Here are some potentially related comments/changes:
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
No response
Environment info
Please confirm that you have searched existing issues in the repo.
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Please confirm which theme type you used for testing.
The text was updated successfully, but these errors were encountered: