Dropbutton size rendered incorrectly in Drupal 9.5.x

Created on 30 August 2023, over 1 year ago
Updated 8 September 2023, over 1 year ago

Problem/Motivation

After upgrading to RC6, "dropbutton" at all "small" and "extrasmall" dropdowns are not rendered correctly (see screenshot).

Steps to reproduce

Looking at the inspector in the browser, I noticed several variables are not defined, causing the final size to be wrong. These variables are Claro theme variables, and somehow not loaded. I'm not using the Claro theme, but it's enabled for Gin in the admin interface.

gin/dist/css/base/gin.css: -webkit-border-start: var(--dropbutton-border-size) solid var(--gin-color-primary) !important;
gin/dist/css/base/gin.css: border-inline-start: var(--dropbutton-border-size) solid var(--gin-color-primary) !important;
gin/dist/css/base/gin.css: width: calc(var(--dropbutton-small-toggle-size) + 1px);
gin/dist/css/base/gin.css: width: calc(var(--dropbutton-extrasmall-toggle-size) + 1px);
gin/styles/base/_dropbutton.scss: border-inline-start: var(--dropbutton-border-size) solid var(--gin-color-primary) !important;
gin/styles/base/_dropbutton.scss: width: calc(var(--dropbutton-small-toggle-size) + 1px);
gin/styles/base/_dropbutton.scss: width: calc(var(--dropbutton-extrasmall-toggle-size) + 1px);

Looking at RC5, there are no calls to those variables, so the dropbuttons are rendered correctly in RC5.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States jmouse888

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

Comments & Activities

  • Issue created by @jmouse888
  • First commit to issue fork.
  • 🇮🇳India roshni27

    I am currently unable to reproduce the issue you mentioned.

  • 🇮🇳India shubham_jain

    Does you have base theme claro?

  • Assigned to shubham_jain
  • 🇺🇸United States jmouse888

    Yes I do have Claro installed. It's at 9.5.10.

    Here is the error in the browser. Same error on the "--dropbutton-border-size". Nothing in the console.

    Thanks for the help.

  • 🇫🇮Finland Alexander Tallqvist

    I am experiencing exactly the same issue after upgrading to the RC6 version of the theme. I am also only using Gin as my admin theme, and our main theme is our own custom theme. Claro is also installed at version 9.5.10.

  • 🇮🇳India shubham_jain

    Hi, I got the error and will work to solve it.

  • 🇸🇪Sweden erikbrgn

    I've looked into this for a bit and this is what I've found:

    Claro is a part of core and uses PostCSS for styling. There's a `dropbutton.pcss.css` in Claro which adds the CSS-variables you're talking of, but in the final CSS `dropbutton.css` the variables are missing. There is just an empty `:root` tag with the same comments as in the PostCSS file, but the variables are missing. I'm guessing that this is a PostCSS issue in core, rather than an issue with Gin. However, relying on variables provided by someone else isn't great and can lead to a lot of issues.

  • 🇫🇮Finland Alexander Tallqvist

    I quickly threw together this patch since I need it now. Might not be the best way to solve the issue, but it works for me. Personally I don't really have an opinion whether or not the variables from Claro should or should not be used.

  • 🇺🇸United States jmouse888

    Okay, after fighting with regex for a half hour, finally got a list of variables Gin is calling from other places.

    --tabledrag-handle-icon-size
    --space-m
    --dropbutton-border-size
    --dropbutton-small-toggle-size
    --dropbutton-extrasmall-toggle-size
    --ck-color-toolbar-border
    --ck-focus-outer-shadow
    --ck-color-text
    --ck-color-base-background
    --ck-color-image-caption-text
    --ck-color-image-caption-background

    All of the ck editor variables are loading fine on the node edit interface, so they are good.

    the 5 variables from Claro are not getting their values (most likely the PostCSS issue #9 pointed out). I'm comparing these values set in RC5 and generating a patch.

  • @shubham_jain opened merge request.
  • 🇮🇳India shubham_jain

    Hi everyone, I have solved the issue and created merge request. Because patch file for css is extra burden.

    So, please review and verify.

  • 🇺🇸United States jmouse888

    Sorry. That #10 patch, while partially working, is not complete. It only addresses the extrasmall dropdowns, not the small ones, or any of the other variables (border size, table drag icon size etc). Also, there is no need to redefine classes as they are already defined in Claro. Simply commenting out the lines in Gin will make the classes fall back to the Claro declarations. Here is a new patch which will comment out all Claro variable calls.

  • 🇫🇮Finland Alexander Tallqvist

    True, I managed to miss a few variables. On another note - do the "border size", "table drag" and "icon size" variables have anything to do with this issue, or should they be fixed somewhere else? If I'm not mistaken, it seems that only the once related to "dropbutton" are relevant (i.e. --dropbutton-border-size, --dropbutton-small-toggle-size and --dropbutton-extrasmall-toggle-size)? To me, #13 seems like a better solution when it comes to this specific issue. I wrote a new patch that targets only the related variables. Thank you for your work so far.

  • Status changed to Needs work over 1 year ago
  • 🇨🇭Switzerland saschaeggi Zurich

    Drupal 10 uses CSS Variables in the output. 9.5.10 seems to still convert them to the actual values.

    Let's add fallback values to the CSS variables for 9.5.x.

    Instead of

    .dropbutton__toggle {
      width: calc(var(--dropbutton-small-toggle-size) + 1px);
         }

    we can do

    .dropbutton__toggle {
      width: calc(var(--dropbutton-small-toggle-size, 2rem) + 1px);
         }

    see also https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_proper...

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India djsagar

    Hi all,

    Patch updated as per suggested changes by @saschaeggi in #16.

    Please review.

  • Status changed to Needs work over 1 year ago
  • 🇨🇭Switzerland saschaeggi Zurich

    Thanks @djsagar

    Moving this back to needs work as the patch from includes unwanted code style changes.

  • 🇮🇳India shubham_jain

    Hi all, I have opened merge request to solve this issue.

    Please review and verify.

  • 🇮🇳India shubham_jain

    Hi all, I have opened merge request to solve this issue.

    Please review and verify.

  • Status changed to Needs review over 1 year ago
  • 🇨🇭Switzerland saschaeggi Zurich
  • Status changed to RTBC over 1 year ago
  • 🇬🇧United Kingdom sergiur London, UK

    Hello! Tried the latest MR and it seems to have solved the issue both small and xsmall dropbuttons:

  • Status changed to Fixed over 1 year ago
  • 🇨🇭Switzerland saschaeggi Zurich

    Thanks y'all 👋

  • Issue was unassigned.
  • 🇨🇭Switzerland saschaeggi Zurich
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024