Overview

Sometimes when loading experience builder (most often, seemingly, after switching between Git branches) many unexpected CSS files are loaded into the page. These extra CSS files such as base.css interfere with the styling of the page by setting things like margin for all h1-h6 tags.

Proposed resolution

I don't think there should be any CSS files loaded that are not explicitly called in by the React app.

Before running drush cr

After running drush cr

Steps to reproduce

There are many situations where this happens, but this is the first reliable way I found to reproduce the symptoms:

  • Olivero needs to be the default theme
  • Install the module 'js_message_test'
  • Clear caches and make /js_message_test_link the first page you visit after the cache clear
  • Then visit the XB UI and the extra, unwanted, CSS files are loaded. (if the XB UI is the first page visited after the cache clear, the problem doesn't seem to happen )
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jessebaker created an issue. See original summary.

hooroomoo made their first commit to this issue’s fork.

bnjmnm’s picture

Issue summary: View changes
bnjmnm’s picture

I updated the steps to reproduce and added a failing e2e test that admittedly does not follow the exact steps as summarized, but still runs into the problem. In the test, it fails due to an error vs a non-passing assertion because the pile of Olivero assets include navigation JS that assumes certain elements are present and it errors when those elements aren't found.

hooroomoo’s picture

Assigned: Unassigned » hooroomoo

Ok found from comment under experience_builder_library_info_alter and previous MRs it's because of Drupal.ajax bringing in Drupal.message that brings in Olivero assets but because the hooks run after a cache clear the current workaround that unsets the drupal.message library isn't getting triggered if a page that adds the library is visited first?

bnjmnm’s picture

Re #6 Yep that's what it looks like. cache_discovery - cid library_info:olivero is the culprit. If this cache item is first generated when the XB UI loads, the $route_name === 'experience_builder.experience_builder' condition is true and the library info cache will omit the extra assets. I suspect when that scenario happens then Olivero risks having some assets missing, but I haven't confirmed this.

hooroomoo’s picture

Status: Active » Needs review

This is admittedly kinda hacky, hopefully this MR can invoke a cleaner solution

hooroomoo’s picture

Assigned: hooroomoo » Unassigned
balintbrews’s picture

Assigned: Unassigned » bnjmnm

I think @bnjmnm would be the best person to review the solution.

bnjmnm’s picture

Assigned: bnjmnm » Unassigned
Status: Needs review » Reviewed & tested by the community

I can't codeowner-signoff because I provided the initial commit with the test, but this solution is AOK - it gets around having to use the libraries info alter hook that is sensitive to the first page visit. What's there is sorta workaroundy, but not moreso than what was removed, and it stops this bug from happening.

lauriii made their first commit to this issue’s fork.

  • lauriii committed 58ed289c on 0.x authored by bnjmnm
    Issue #3485842 by bnjmnm, hooroomoo, jessebaker: Many css files...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed
wim leers’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.