slick.theme.css overrides Blazy CSS

Created on 11 September 2024, 2 months ago

Problem/Motivation

CSS code in slick.theme.css overrides Blazy's css and break view.

Steps to reproduce

This is very likely an extremely niche and specific case due to the nested nature of the CSS code involved. Issue can be observed by looking at the "Feature content" section of privacyinternational.org frontpage (archive.org version of September 8).

This is what the website looked before we updated Slick: https://web.archive.org/web/20240901020323/https://privacyinternational....

As you can see the "Featured content" section looks different. Upon inspection of the div class="view-teaser view-teaser--four view view-frontpage view-id-frontpage view-display-id-page_1 js-view-dom-id-fd3ab27ef8d9b01d283e9c9f3cb9cde37c49b11e6c5d1afb0c8f554cf10eea21", one can see this CSS applied:

.view, .view .view-content, .block .view, .block .view .view-content {
  display: block;
}

When disabling this property, the elements revert to the correct layout and CSS.
This code seems to come from slick.theme.css, line 13, a fix for Olivero Grid:

/* Fix for unnecessary Olivero Grid surprises causing Slick excessive height. */
div[class*="view-slick"],
div[class*="view-slick"] .view-content,
div[class*="view-blazy"],
div[class*="view-blazy"] .view-content {
  display: block;
}

If I understand that code correctly and while I'm unsure what its purpose is, it seems that a wildcard selector for all Blazy views class might be the culprit.

Proposed resolution

Unsure as I don't know what the code intended fix was. I'm guessing adding a selector to specify that this should only apply to slick elements is the answer. Possibly something like:

div[class*="view-slick"].div[class*="view-blazy"]

(I haven't touched CSS in many years so please excuse me if this is not correct at all or not up to standards, there's a reason I'm not proposing a patch!)

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @privacyint
  • Status changed to Postponed: needs info 2 months ago
  • 🇮🇩Indonesia gausarts

    Thank you.

    Mind screenshoting before and after for better spots?

    I don't always have laptop nearby.

    About the reason, the convention is any modules should work with core defaults OOTB, hence Olivero is D10 theme default. Unlike the previous Bartik, Olivero is very advanced in CSS, thus posing more advanced challenges to contribs. The explanation is right above the fix:

    /* Fix for unnecessary Olivero Grid surprises causing Slick excessive height. */
    

    The problem also happens at Splide slider. Normally as a Views block and in a grid. No problems are outside these two conditions.

    The actual problem:
    Both Slick and Splide have massive widths, only hidden partially to make sense in sliding displays. It was fine so far, until D10 Olivero adds problematic CSS rules, and to my investigation, pretty much useless, that is by allowing the child elements' widths to expand beyond its parent and reveal excessive widths and heights, while they should be hidden in the case of these carousels.

    However I am interested in seeing your actual by-products.

  • Status changed to Active 2 months ago
  • Thanks for the quick response. Full page screenshot attached, the top element is Slick Carousel (loaded as a block) but the affected element is a part of a Drupal view used for the frontpage.

    We have our own set of classes and CSS, the display:block property basically overrides a display:grid property.

  • Status changed to Fixed 2 months ago
  • 🇮🇩Indonesia gausarts

    That spots the issue better, thanks.

    Let's make it clear:

    • The fix is fixing core Olivero integration problem, and it works for core OOTB stuffs. We cannot nego core stuffs for now.
    • I understand it breaks your previous custom works, but you must understand it is your own custom works. We are concerning more about the most common use cases here, things like OOTB. Core integration wins over custom works. That is the ugly truth you might never hear nor want to. And the fix corrects it very well.

    This might be a regression to old D9 context, but not a bug in D10 context.

    It fixed the new bug introduced by Olivero at D10. Without the fix, similar issue like Splide's would be reported here.

    Solutions:
    Just update and override that rule in your own custom CSS, be sure to have more specificity or exact CSS class to avoid issues at other areas to win over this module.

    I hope you understand such a situation.

  • Status changed to Active 2 months ago
  • We've already fixed it on our end but wanted to flag as it didn't seem like the best approach for a module to have CSS that applies outside of its own scope.

    Our custom CSS is already applied to our own defined classes and ids. No other module we use overrides it. What happens here is that when Slick loads there is a CSS rule that overrides all .view, .view .view-content, .block .view, .block .view .view-content classes with a custom rule. That simply didn't seem right to us.

    We might have a very specific use case and I understand it might not be worth fixing as it doesn't seem to affect many people. We simply assumed it was worth flagging as it might affect others at some point.

    My guess is that you might be able reproduce this bug without any custom css but using blazy grid display and get similar results but I could be wrong. In any case, we'll stick to a fix in our CSS for now.

  • 🇮🇩Indonesia gausarts

    On second thought, makes sense, out-of-scope rule is not right. It was more a quick and dirty fix to D10 Olivero integration.

    IIRC, the latest Blazy in 3.x already sniffs for Slick and Splide in Views, and provides the more scoped CSS rule overrides.

    So this Slick kill-em-all rules could be removed later after another check.

    Thank you for good communication and keeping civil!

  • 🇨🇦Canada robbdavis

    This 'fix' is also bleeding into my theme. I've got many .view divs that are being displayed with flexbox. Forcing the .view into a display:block breaks the theme.

    • gausarts committed af66388e on 3.0.x
      Issue #3473516 by privacyint: slick.theme.css overrides Blazy CSS
      
  • 🇮🇩Indonesia gausarts

    Removed the quick-dirty rules.

    FYI, the fix is still needed, otherwise Slick has gargantuan width and height.

    Only now left to Blazy to be more scoped, and should no longer bleed.
    If for some reason the gargantuan width issue crops up somewhere else, Blazy scoped rules fail due to being too scoped.

    To solve the issue, simply copy the removed rules, or adjust the ancestor selector to not have problematic grid rules, into your theme as needed.

    Thank you for contribution!

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

Production build 0.71.5 2024