Problem/Motivation

If a component is a pattern (ie: include multiple components, like a header or a footer), it needs to be wrapped in a dom element or some sub components will be "draggable" in the Display Builder "builder" Island and will raise an error when moved as they do not exist in the config.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

Title: API errors on builder » Component patterns must be wrap to work in the builder
Issue summary: View changes
pdureau’s picture

pdureau’s picture

2 infos which may be useful.

A pattern source tree has always a single root, which is the selected source from which the pattern entity has been created.
https://git.drupalcode.org/project/display_builder/-/blob/1.0.x/src/Enti...

BuilderPanel::hasMultipleRoot() is already checking if a renderable has multiple HTMl elements at the root:
https://git.drupalcode.org/project/display_builder/-/blob/1.0.x/src/Plug...

And wrapping it if necessary:

   elseif (!$this->useAttributesVariable($build) || $this->hasMultipleRoot($build)) {
      $build = [
        '#type' => 'html_tag',
        '#tag' => 'div',
        '#attributes' => ['class' => $classes],
        'content' => $build,
      ];
    }

But it is called only from ::buildSingleBlock(), so not for components.