[wp-trac] [WordPress Trac] #53569: Block widgets editor is hidden if a block enqueues 'wp-edit-post' stylesheet
WordPress Trac
noreply at wordpress.org
Fri Jul 30 09:44:41 UTC 2021
#53569: Block widgets editor is hidden if a block enqueues 'wp-edit-post'
stylesheet
-------------------------------------------------+-------------------------
Reporter: dlh | Owner: zieladam
Type: defect (bug) | Status: closed
Priority: normal | Milestone: 5.8
Component: Widgets | Version: 5.8
Severity: normal | Resolution: fixed
Keywords: has-patch dev-reviewed fixed-major | Focuses:
commit |
-------------------------------------------------+-------------------------
Comment (by seanvarnham):
@desrosj, thanks for this! I've spent the last couple hours trying to find
out any information on this - presumably as it's new.
Could you point us in the direction of a fix please? I've narrowed the
issue down to the code in our agency's blocks plugin:
{{{
add_action( 'enqueue_block_editor_assets', 'enqueue_editor_assets' );
function enqueue_editor_assets() {
wp_enqueue_script(
'block-editor-assets',
plugins_url('dist/editor_script.js', __FILE__),
array(
'wp-blob',
'wp-block-editor',
'wp-blocks',
'wp-components',
'wp-compose',
'wp-data',
'wp-date',
'wp-dom-ready',
'wp-edit-post', // this looks like the problem ??
'wp-element',
'wp-hooks',
'wp-html-entities',
'wp-i18n',
'wp-keycodes',
'wp-plugins',
),
BGB_VERSION
);
}
}}}
Replying to [comment:13 desrosj]:
> In [changeset:"51393" 51393]:
> {{{
> #!CommitTicketReference repository="" revision="51393"
> Widgets: Warn when `wp-editor` script or `wp-edit-post` style is
enqueued in widgets editor
>
> It is common that plugins erroneously have `wp-editor` or `wp-edit-post`
as a
> dependency in a script that is loaded in the new widgets editor. This is
a smell
> since both `@wordpress/editor` and `@wordpress/edit-post` assume the
existence
> of a global "post" object which the widgets editor does not have.
>
> [51387] fixes the user-facing errors typically caused by this mistake,
but we
> can go a step further and warn developers about this by calling
> `_doing_it_wrong()` when we detect that the `wp-editor` script or `wp-
edit-post`
> style is enqueued alongside `wp-edit-widgets` or `wp-customize-widgets`.
>
> Props zieladam, spacedmonkey, TimothyBlynJacobs, andraganescu, dlh,
noisysocks.
> Merges [51388] to the 5.8 branch.
> Fixes #53569. See #53437.
> }}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53569#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list