Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#45279 closed defect (bug) (worksforme)

The order of the Gutenberg stylesheets affects the UI

Reported by: afercia's profile afercia Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-screenshots
Focuses: ui Cc:

Description

Tested on WordPress /branches/5.0 with Twenty Seventeen.

  • create a post
  • add a cover image block
  • notice the block UI has a black background and it's taller than expected

http://cldup.com/SGxish1zmi.png

Turns out the wp-components stylesheet is printed out before the wp-block-library stylesheet:

http://cldup.com/jfnZp46QkI.jpg

While in the Gutenberg plugin everything looks fine because the order is different: wp-block-library is printed out before wp-components:

http://cldup.com/F9pK6C0tDN.jpg

I'd tend to think either the order of the stylesheets should be guaranteed (and documented) or the Gutenberg styles shouldn't be affected by the order. The second option would probably lead to an increased CSS selector specificity, which is not desirable.

Changing the order in script-loader.php fixes it for me, but I'm not sure it's the best option.

Note: the black background and taller height are meant to be used for the cover image "overlay" when an image has been inserted, see https://github.com/WordPress/gutenberg/pull/10291
On the other hand, I guess this is a general issue that potentially applies to all the Gutenberg UI.

Attachments (1)

45279.diff (581 bytes) - added by desrosj 6 years ago.

Download all attachments as: .zip

Change History (14)

#1 @ocean90
6 years ago

I think it should follow the dependencies tree of the scripts. Since block-library depends on components the current order would be correct in core, although not defined as such, yet.

Last edited 6 years ago by ocean90 (previous) (diff)

#2 @desrosj
6 years ago

  • Keywords needs-patch added

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


6 years ago

@desrosj
6 years ago

#4 @desrosj
6 years ago

I am able to reproduce the issue using the Twenty Nineteen theme with and without the package updates from Gutenberg 4.5.

45279.diff fixes the issue, but the dependency is backwards. It's possible the CSS dependencies do not match the JS ones.

Writing out an update here made me think of something else to try. I thought that when registering a style, dependencies specified need to have been previously registered. But that does not appear to be true.

Last edited 6 years ago by desrosj (previous) (diff)

#5 @desrosj
6 years ago

  • Keywords has-patch added; needs-patch removed

Checking into the implementation in the plugin a bit further, the CSS dependencies do not always match the packages.

I can reproduce this issue in the plugin by adding wp-components as a dependency of wp-block-library.

I think 45279.diff is probably the right approach here, but changing the stylesheet loading order could cause some other styling issues to pop up.

#6 @youknowriad
6 years ago

In my opinion wp-components and wp-block-library are both completely unrelated styles.

  • wp-block-library is about the frontend styles of The blocks (not the editor styles, this wp-edit-blocks)
  • wp-components is about the generic components to build the UI

So no style should depend on the other in this case. I think a better fix would be to ensure these two styles don't conflict no matter the loading order. I'd be fine with a temporary fix like suggested here but we should follow up on the Github repository to fix the root issue.

#7 @gziolo
6 years ago

I agree with Riad, that we should investigate why this conflict happens in the first place. Those styles shouldn't depend on each in this direction. It should be probably like this:

wp-components < wp-editor < wp-block-library < wp-edit-blocks

I think it's fine to move forward with the proposed fix for now given that this is how it works in Gutenberg as of today. We should definitely revisit it very soon.

#8 @desrosj
6 years ago

Agreed! I opened GB-12179 to explore this upstream.

#9 @desrosj
6 years ago

Just opened GB-12187 to address this in the packages.

I am not sure if updating just one package is possible, but if the affected package can be released and then bumped in Core, the temporary fix in 45279.diff would not be needed.

#10 @desrosj
6 years ago

  • Keywords close added; has-patch removed

This has been fixed upstream and can be resolved in core once the package is released and the version is bumped in Core.

Leaving this open until that happens and this is fully tested and confirmed.

Last edited 6 years ago by desrosj (previous) (diff)

#11 @noisysocks
6 years ago

r43935 contained the upstream fix. I can no longer reproduce this issue in the 5.0 branch.

#12 @youknowriad
6 years ago

  • Keywords fixed-5.0 added

#13 @ocean90
6 years ago

  • Keywords close fixed-5.0 removed
  • Milestone 5.0 deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.