esmero / archipelago_subtheme

Bare bone Archipelago Bootstrap4 Theme
0 stars 5 forks source link

New config setting in bootstrap_barrio 5.5.13 #40

Open aksm opened 11 months ago

aksm commented 11 months ago

What?

Because there is a new config setting bootstrap_barrio_button_type: 'primary' added as of bootstrap_barrio 5.5.13, a composer update will muck up the settings. Adding the new setting to our configs here, archipelago-deployment, and archipelago-deployment-live resolves the issue.

DiegoPino commented 11 months ago

@aksm can you please point us to where in the code /how that unrelated config hits the fan? Thanks

aksm commented 11 months ago

@DiegoPino Will investigate further, but adding the setting to configs before deploying resolved the issue of buttons not appearing in the webform after composer update.

aksm commented 11 months ago

@DiegoPino In bootstrap_barrio.theme (below) after a composer update, the setting is null if it's missing in config so the button can't be generated:

    $button_type = theme_get_setting('bootstrap_barrio_button_type');
    if (is_object($variables['attributes']['class'])) {
      \Drupal::logger('bootstrap_barrio')->notice(implode($variables['attributes']['class']->value()));
      if (!in_array('btn', $variables['attributes']['class']->value())) {
        $variables['attributes']['class']->addClass('btn');
      }
      if (empty(array_intersect($button_types, $variables['attributes']['class']->value()))) {
        if ($button_is_outline) {
          $variables['attributes']['class']->addClass('btn-outline-' . $button_type);
        }
        else {
          $variables['attributes']['class']->addClass('btn-' . $button_type);
        }
      }
DiegoPino commented 11 months ago

@aksm ok! can you dig deeper? What I see there is what defines the classes. Where is the button not generated at all if no classes?

aksm commented 11 months ago

@DiegoPino sorry, I should've added the whole snippet, the above block continues with the following:

      if ($button_size && empty(array_intersect($button_sizes, $variables['attributes']['class']->value()))) {
        $variables['attributes']['class']->addClass($button_size);
      }
    }
    else {
      if (!in_array('btn', $variables['attributes']['class'])) {
        $variables['attributes']['class'][] = 'btn';
      }
      if (empty(array_intersect($button_types, $variables['attributes']['class']))) {
        if ($button_is_outline) {
          $variables['attributes']['class'][] = 'btn-outline-' . $button_type;
        }
        else {
          $variables['attributes']['class'][] = 'btn-' . $button_type;
        }
      }

That very last else is the one affecting the webform.

DiegoPino commented 11 months ago

@aksm so question. Why do other buttons in other places work? I'm ok with adding "primary" as default for that property, I just don't get why that is an issue. Of course feel free to make pulls for this, just the logic makes no sense to me.

aksm commented 11 months ago

@DiegoPino From my testing the other buttons in the webform disappear with a composer update as well.