Make WordPress Core

Opened 3 years ago

Closed 3 years ago

#54752 closed defect (bug) (reported-upstream)

`load-styles.php` stylesheet not properly added in the editor

Reported by: walbo's profile walbo Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.9
Component: Editor Keywords:
Focuses: Cc:

Description

In 5.9-RC1 the editor throws a warning in the console that says the load-styles.php?... stylesheet was not properly added.

Stylesheet  was not properly added.
For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles). <link rel="stylesheet" href="http://wpdev.test/wp-admin/load-styles.php?c=1&amp;dir=ltr&amp;load%5Bchunk_0%5D=dashicons,admin-bar,buttons,media-views,editor-buttons,wp-components,wp-block-editor,wp-nux,wp-reusable-blocks,wp-editor,common,&amp;load%5Bchunk_1%5D=forms,wp-reset-editor-styles,wp-block-library,wp-edit-blocks,wp-edit-post,wp-block-directory,wp-format-library,admin-menu,dashbo&amp;load%5Bchunk_2%5D=ard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-pointer,widgets,site-icon,l10n,wp-auth-check,wp-block-library-the&amp;load%5Bchunk_3%5D=me&amp;ver=5.9-RC1" media="all">

Steps to reproduce:

  1. Create a new post
  2. Insert a buttons block.
  3. Click on the button
  4. Confirm the warning is thrown in the console.

Attachments (1)

styles-console-warning.gif (391.0 KB) - added by walbo 3 years ago.

Download all attachments as: .zip

Change History (19)

#1 @SergeyBiryukov
3 years ago

  • Component changed from General to Editor
  • Milestone changed from Awaiting Review to 5.9

#2 @hellofromTonya
3 years ago

  • Keywords reporter-feedback added

Hmm, I was able to reproduce it only once with RC1, but on repeated tries, it works each time. Also tried on current 5.9-branch and couldn't reproduce it.

Hey @walbo, let's see if there's a pattern for investigation:

  • Does it happen every time the buttons block is added? Or only the first time?
  • Does it happen with a block theme, like TT2 activated?
  • What about with a non-block theme like TT1?
  • Does it happen with with or without the Gutenberg plugin activated?

#3 @walbo
3 years ago

Thanks for testing @hellofromTonya

Have done some more testing (5.9-RC1-52550) and here is my findings:

  • It happends every time the preview of a block is loaded. (It's triggered in the button block view because of the styles preview, but I can trigger the warning in the block inserter when I hover a block that has a preview)
  • It only happends when SCRIPT_DEBUG is set to false.
  • It happens in both block and non-block thems (tested TT2, TT1 and a custom block theme)

It happens in core, but can't reproduce it when Gutenberg (12.3.1) is activated, so may already be fixed there. I can do some more testing tomorrow to see if I can find the commit that fixed in there.

Last edited 3 years ago by walbo (previous) (diff)

This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.


3 years ago

#5 @juhise
3 years ago

I have also tried to reproduce this.
Here is my finding:

  1. I could also reproduce this only when SCRIPT_DEBUG was set to false.
  2. With Gutenberg activated, couldn't reproduce.
  3. I also got this, when I search any block while adding

#6 @walbo
3 years ago

  • Keywords reporter-feedback removed

Did some more digging and think I know the issue.

The warning are triggered by stylesheetCompat function in Gutenberg. The function loads all stylesheets that contains editor-styles-wrapper, wp-block, or wp-block-* class selectors into the iframe that is used in previews.

When the SCRIPT_DEBUG is set to false the load-styles.php?... concatinates all editor assets and stylesheetCompat will pick up the stylesheet because it now meets the conditions to include it in the iframe.

From what I can understand none of the styles that are included in wp_add_iframed_editor_assets_html shouldn't be concatinated into load-styles, but someone with a deeper understanding of how the editor handles styles should be included to verify this.

This ticket was mentioned in PR #2141 on WordPress/wordpress-develop by walbo.


3 years ago
#7

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/54752

Just a proof of cocept to verify a bug is fixed. Not sure this is the way to handle it.

#8 @walbo
3 years ago

  • Keywords has-patch removed

Added a small patch that doesn't include the iframe assets in load-styles.php. It does solve the warning for me, but I don't think this is the correct way to handle it. So the patch is more a proof of concept to verify where the bug is.

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


3 years ago

#10 @hellofromTonya
3 years ago

Looking at the proof of concept I wonder: What changed in the editor handles styles that is impacting this bug? Please note, the wp-includes/class.wp-styles.php file did not change during the 5.9 cycle except for a docs change in July.

Would be good to consult with the editor team to discover the root cause. cc @noisysocks

This ticket was mentioned in Slack in #core-editor by walbo. View the logs.


3 years ago

This ticket was mentioned in Slack in #core-editor by mamaduka. View the logs.


3 years ago

#13 @noisysocks
3 years ago

This was discussed in last night's core editor chat.

I agree with Ari's comment:

At this point, the warning does more harm than good. The intention behind it is good, but if we can't fix the current implementation for 5.9, then temporarily removing these warnings makes sense

#14 @noisysocks
3 years ago

@aristath @mamaduka @jorgefilipecosta: Would one of you like to open a Gutenberg PR which does this?

#15 @Mamaduka
3 years ago

I will open PR in the repo.

PR is ready for review - https://github.com/WordPress/gutenberg/pull/37937

Last edited 3 years ago by Mamaduka (previous) (diff)

#16 @hellofromTonya
3 years ago

Update: @Mamaduka's PR has been merged into the Gutenberg repo.

@noisysocks please include in the RC3 backports. Thank you!

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


3 years ago

#18 @audrasjb
3 years ago

  • Milestone 5.9 deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

Merged in https://core.trac.wordpress.org/changeset/52596.
Closing as reported upstream.

Note: See TracTickets for help on using tickets.