Skip to content
Snippets Groups Projects
Commit 2e43576e authored by Florent Torregrosa's avatar Florent Torregrosa Committed by Pierre Dureau
Browse files

Issue #3486050 by grimreaper, pdureau: Fix Layout Builder drag & drop and...

Issue #3486050 by grimreaper, pdureau: Fix Layout Builder drag & drop and remove temporarily UI Styles support
parent c38d4dea
No related branches found
No related tags found
1 merge request!257Issue #3486050 by grimreaper, pdureau: POC Layout Builder: fix d&d and UI Styles support
Pipeline #342404 passed
......@@ -4,7 +4,6 @@ namespace Drupal\ui_patterns_layouts\Element;
use Drupal\Core\Render\Element;
use Drupal\Core\Security\TrustedCallbackInterface;
use Drupal\Core\Template\Attribute;
/**
* Alter the rendering of a component element.
......@@ -39,9 +38,8 @@ class ComponentAlterer implements TrustedCallbackInterface {
foreach (Element::children($element[$region_id]) as $block_id) {
$element["#slots"][$region_id][$block_id] = $element[$region_id][$block_id];
}
if (isset($element[$region_id]['#attributes']) && isset($element['#slots'][$region_id])) {
$element['#region_attributes'][$region_id] = new Attribute($element[$region_id]['#attributes']);
// Support for drag&drop and other attributes manipulation.
// Support for drag&drop and other attributes manipulation in preview.
if ($element['#layout']->isInPreview() && isset($element[$region_id]['#attributes']) && isset($element['#slots'][$region_id])) {
$element['#slots'][$region_id] = [
'#type' => 'html_tag',
'#tag' => 'div',
......
......@@ -171,4 +171,16 @@ class ComponentLayout extends LayoutDefault implements ContainerFactoryPluginInt
return $dependencies;
}
/**
* Getter for the inPreview attribute.
*
* As there is currently no getter in the base class.
*
* @return bool
* If the layout is in preview.
*/
public function isInPreview(): bool {
return $this->inPreview;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment