[wp-trac] [WordPress Trac] #53327: Twenty Twenty editor stylesheet causing issues on block Widgets screen

WordPress Trac noreply at wordpress.org
Tue Jun 15 01:11:04 UTC 2021


#53327: Twenty Twenty editor stylesheet causing issues on block Widgets screen
---------------------------+---------------------
 Reporter:  isabel_brison  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  5.8
Component:  Bundled Theme  |     Version:
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+---------------------

Comment (by noisysocks):

 `enqueue_block_editor_assets` is the hook we're talking about. It's
 intended to be used for blocks to enqueue their scripts and styles but
 Twenty Twenty is using it to enqueue editor styles because of a limitation
 in `add_editor_style()`. See GB18571 for more about that.

 You can see this issue manifest in a different way by activating Twenty
 Twenty, creating a new post, opening Preferences, and disabling "Use theme
 styles". The editor should appear unsettled but, because Twenty Twenty is
 using `enqueue_block_editor_assets`, the styles are still loaded and
 toggling the preference does nothing.

 There's a few potential solutions to this issue:

 1. We could fix the underlying issue with `add_editor_style()` which
 caused Twenty Twenty to use this workaround in GB18571. I don't think it's
 feasible to do this in time for WordPress 5.8, though.

 2. We could add editor styles to the widgets editor. GB26163 tracks this.
 I don't think that it is feasible to do this in time for WordPress 5.8
 though as there are some design considerations (see GB32449) which need to
 be thought out. Also, this wouldn't fix the underlying issue because
 Twenty Twenty would still style the editor even when "Use theme styles" is
 disabled.

 3. We could add an "are editor styles enabled?" check to Twenty Twenty's
 `twentytwenty_block_editor_styles` function which does not add the styles
 if editor styles are disabled. This might not be possible though, as the
 "Use theme styles" setting is stored in `localStorage` and not accessible
 by PHP. It would be a nice solution if possible though.

 4. We could have the widgets screen fire a different hook to
 `enqueue_block_editor_assets`. For example,
 `enqueue_widgets_block_editor_assets`. This would fix the problem with
 Twenty Twenty but has the very unfortunate side effect of requiring that
 all third party blocks need to enqueue their scripts and styles in both
 `enqueue_block_editor_assets` and `enqueue_widgets_block_editor_assets`.
 That is, the widgets editor would not support third party blocks by
 default.

 5. We could add an "is this the widgets screen?" check to Twenty Twenty's
 `twentytwenty_block_editor_styles` function which does not add the styles
 if e.g. `$pagenow === 'widgets.php`. This doesn't solve any of the
 underlying issues but, of course, is very doable in time for WordPress
 5.8.

 So, in my view, (1) is the proper fix but perhaps not feasible for
 WordPress 5.8. (3) is a good alternative but perhaps not possible. (5) is
 potentially the best temporary solution.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53327#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list