Doesn't remove core Layout Builder styling with Drupal 10.1 Aggregation

Created on 26 July 2023, over 1 year ago
Updated 3 October 2023, about 1 year ago

Problem/Motivation

With Drupal 10.1's new CSS/JS aggregation changes, Gin LB doesn't remove the core layout builder styling and is both stylings render.

Steps to reproduce

  1. Upgrade to Drupal 10.1
  2. Enable Gin LB and other related modules
  3. Open Layout Builder in a content type that has it set to be used.
  4. Notice the styling issues

Proposed resolution

It seems that the core styling is just not being removed. The functionality is in the gin_lb.module file in the gin_lb_css_alter hook but doesn't seem to run when CSS/JS aggregation is turned on.

I'm not too sure how to solve this.

Remaining tasks

Fix the issue of core Layout Builder styling not being removed when CSS/JS aggregation is turned on.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇦Canada jorielsaikali

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jorielsaikali
  • 🇺🇦Ukraine Goodmood

    I confirm, that this is the issue. Have the same problem after upgrade to 10.1 (from 9)

  • 🇧🇴Bolivia alvarito75 Cochabamba

    I have the same issue :/

  • 🇧🇴Bolivia alvarito75 Cochabamba

    I created a patch to remove an edge case since this only happens with a block with multiple autocomplete field

  • 🇧🇴Bolivia alvarito75 Cochabamba

    There is a new patch created based on the current branch of Gin Layout Builder 1.0.0-rc4

  • Assigned to Grimreaper
  • Status changed to Needs work over 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    I think hook_css_alter and aggregating all Gin LB CSS into one file has reached its limit because then it is not possible to declare proper library dependency to control the CSS load ordering.

    Maybe a big refactoring of the CSS of the module is needed...

    Adding related issues because the solution may be common.

  • Issue was unassigned.
  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇧🇴Bolivia alvarito75 Cochabamba

    I'm still having these issues.

    What I did recently:

    • Gin theme updated from to RC4 -> RC5
    • Gin 8.x-3.0-rc5
    • Still Drupal 10.1.2

    These tests I did might help understand the issue in more use cases, please see attached images:

    • Adding a block
    • Working with sortable content
    • I added a pair of images when the CSS/JS Aggregation is turned off
    • I added a pair of images when the CSS/JS Aggregation is turned on
    • The images are about adding blocks and editing content with sortable capabilities

    Some things I tried:

    1. I created new custom libraries and copied the Gin LB libraries into my custom module and I turned on the CSS/JS Aggregation to see if the issue was still there and I got the same problem
    2. I debugged the CSS and JS in Firefox but it seems CSS/JS from Gin LB is not being aggregated
    3. Also I noticed that for the Gin LB CSS, the variables are not working properly in Chrome but they work well in Firefox

    I hope this info is useful while I'll be

    Btw I just saw another release for Gin, I'll test it and let you know

  • 🇨🇭Switzerland phma Basel, CH

    I was trying to get gin_lb to work on our site. But going to 10.1 and enabling aggregation caused the core CSS to reapply which resulted in a rather messy output.

    I did some debugging and hook_css_alter does still run. But it seems like aggregation relies on the libraries more than the individual files. As a workaround, I managed to disable the libraries using libraries-override. Just paste the code below into your theme's info file. Refactoring is probably a good idea. Unfortuantly, those libraries overrides only work for themes. But maybe we can use hook_libraries_info_alter instead?

    libraries-override:
      layout_builder/drupal.layout_builder:
        css:
          theme:
            css/layout-builder.css: false
      core/drupal.dialog.off_canvas:
        css:
          base:
            misc/dialog/off-canvas/css/reset.css: false
            misc/dialog/off-canvas/css/base.css: false
            misc/dialog/off-canvas/css/utility.css: false
          component:
            misc/dialog/off-canvas/css/button.css: false
            misc/dialog/off-canvas/css/drupal.css: false
            misc/dialog/off-canvas/css/form.css: false
            misc/dialog/off-canvas/css/table.css: false
            misc/dialog/off-canvas/css/details.css: false
            misc/dialog/off-canvas/css/messages.css: false
            misc/dialog/off-canvas/css/tabledrag.css: false
            misc/dialog/off-canvas/css/throbber.css: false
            misc/dialog/off-canvas/css/dropbutton.css: false
            misc/dialog/off-canvas/css/titlebar.css: false
            misc/dialog/off-canvas/css/wrapper.css: false
      core/drupal.autocomplete:
        css:
          theme:
            assets/vendor/jquery.ui/themes/base/theme.css: false
      core/drupal.dialog:
        css:
          component:
            assets/vendor/jquery.ui/themes/base/dialog.css: false
      system/base:
        css:
          component:
            css/components/tabledrag.module.css: false
    
  • 🇬🇧United Kingdom catch

    The problem is the call to gin_lb_is_layout_builder_route(). Needs to check for the presence of a layout builder library or similar instead.

  • 🇨🇭Switzerland phma Basel, CH

    Thanks @catch. I can confirm that this approach works. I didn't realise the hook is being executed again during aggregation.

    See patch attached for a quick fix. Probably needs more thought on what we check and some cleanup.

  • 🇮🇳India shubham_jain

    hi everyone, I need to solve this error I need to add code in comment#10 that in my theme and apply the patch in the module file.

    Is that right. Correct me if I am wrong.

  • 🇨🇭Switzerland phma Basel, CH

    hi @shubham_jain. I've not done exessive testing on it yet, but you can use either method. Both should produce the same effect, but may have different side effects depending on your installation.

  • Status changed to Needs review about 1 year ago
  • 🇬🇧United Kingdom catch

    Moving to needs review for #12.

  • 🇧🇴Bolivia alvarito75 Cochabamba

    Thanks, @phma for the patch

    After my test, I can verify it is working for most cases but still have edge cases, below are the versions of the project I'm working on:

    Drupal Setup

    • Gin theme 8.x-3.0-rc5
    • Gin Layout Builder 1.0.0-rc4
    • Drupal 10.1.2

    The edge case is for an autocomplete field, please see the attached image.

    I'll continue testing

  • 🇮🇳India shubham_jain

    Thanks @phma, your patch solved the issue for me.

  • Assigned to Grimreaper
  • 🇫🇷France Grimreaper France 🇫🇷
  • Status changed to RTBC about 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷

    I have tested with the latest dev version of gin_lb on Drupal 10.1.3.

    And on a Drupal 9.5.10.

    It fixes the problem!

    Thanks a lot for the patch! I will merge it.

  • @grimreaper opened merge request.
  • Issue was unassigned.
  • Status changed to Fixed about 1 year ago
  • 🇫🇷France Grimreaper France 🇫🇷
  • 🇨🇦Canada vincent signoret

    Like mentioned in #16 I also have an with the autocomplete element. I'm not sure if it's related to this problem.

  • 🇺🇸United States rpearl

    Also finding issues when trying to use the Field Group module along with this. You can't group items in an accordion or tabs, they just won't work. Probably should be another ticket, but because of things like this, the resolution/patch for this current issue may need to be thought about.

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

Production build 0.71.5 2024