Preview is not accurate for the site branding block

Created on 6 February 2025, 5 months ago

Overview

I have modified the theme settings for Olivero to customize the primary color to look like this:

However, when looking at the preview for the site branding, it's still using the default blue:

Steps to reproduce:

  1. Install site with Olivero and XB
  2. Change primary base color in /admin/appearance/settings/olivero
  3. Visit XB to preview the "Site Branding Block" by hovering over it in the library
  4. Observe the block being rendered in the default blue

Proposed resolution

User interface changes

🐛 Bug report
Status

Active

Version

0.0

Component

Page builder

Created by

🇫🇮Finland lauriii Finland

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

Comments & Activities

  • Issue created by @lauriii
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    AFAICT this is because some of Olivero's styles (aka the default theme aka system.theme:default in the screenshot) are not injected into the component's css and/or header_js, for its default_markup.

    IOW: \Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\BlockComponent::getClientSideInfo() would need to change

    return ['build' => $this->renderComponent([], $component->uuid())];
    

    to something like

    $build = $this->renderComponent([], $component->uuid());
    // Attach the default theme's …
    $build['#attached']['library'][] = …
    return ['build' => $build];
    

    Although arguably, this is a bug in \Drupal\system\Plugin\Block\SystemBrandingBlock::build() … but as far as that implementation is concerned, XB's rendering-in-isolation of this block is an unexpected use case.

    But I think I see a possible heuristic for this:

    $build = $this->renderComponent([], $component->uuid());
    if (!empty(array_intersect($build['#cache']['tags'], ['config:system.site', 'config:system.theme'])) {
      // Attach the default theme's …
      $build['#attached']['library'][] = …
    }
    return ['build' => $build];
    

    Something like that?

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Production build 0.71.5 2024