Can't assign slots in layout builder

Created on 7 April 2025, 18 days ago

Problem/Motivation

If I use Media source width UI Patterns UI to assign a background image in Layout Builder the image only appears on entity view not in layout builder edit mode.

Steps to reproduce

Add Media (ui_patterns_settings) in UI Patterns UI and open it in layout builder.

Problem

Following code prevents slots to be rendered:

Drupal\ui_patterns\Element\ComponentElementBuilder:201
protected function buildSlot(array $build, string $slot_id, array $definition, array $configuration, array $contexts): array {
    if (isset($build['#slots'][$slot_id])) {
      // Keep existing slots. Used by ComponentLayout for example.
      return $build;
    }

The slot is prefilled by the "add Block" Button. So the region is not rendered successfull
For entity view the slot $build['#slots'][$slot_id] is empty so the setted slots are rendered.

Lets discuss that.

Solutions

Following solutions can be suitable:

  • 1. Remove the if and just add the existing block at the end of the source
  • 1. Remove the if and just add the existing block at the end of the source
  • 2. Add the block as source to ui patterns not as region in the build array.
🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany Christian.wiedemann

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

Comments & Activities

Production build 0.71.5 2024