Problem/Motivation
When using components as layouts, we can't drag and drop blocks inside a slot (layout's region) or between slots.
Similar UI Patterns 1.x issue: #3460456: Layout Builder: drag&drop of blocks inside component slots is not working
Proposed resolution
This seems to work:
--- a/modules/ui_patterns_layouts/src/Element/ComponentAlterer.php
+++ b/modules/ui_patterns_layouts/src/Element/ComponentAlterer.php
@@ -41,6 +41,12 @@ class ComponentAlterer implements TrustedCallbackInterface {
}
if (isset($element[$region_id]['#attributes'])) {
$element['#region_attributes'][$region_id] = new Attribute($element[$region_id]['#attributes']);
+ $element["#slots"][$region_id] = [
+ "#type" => "html_tag",
+ "#tag" => "div",
+ "#attributes" => $element[$region_id]['#attributes'],
+ "content" => $element["#slots"][$region_id],
+ ];
}
unset($element[$region_id]);
}
Remaining tasks
What about UI Styles ?
Issue fork ui_patterns-3464894
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pdureau commentedAre we sure this wrapper is added only in Layout Builder preview and not elsewhere?
Comment #3
grimreaperI will try with UI Styles Layout Builder, but I think this wrapper is needed everywhere as soon as the component is used as a layout.
Comment #4
grimreaperI can't test with UI Styles until #3465497: Type error with callback is fixed.
Comment #5
pdureau commentedProposal:
Comment #6
grimreaperComment #8
grimreaperComment #10
pdureau commentedComment #11
pdureau commented