- Issue created by @goz
Using last ui_patterns dev 2.0.x version 0d3fa1445108d92f17d6ba46de26a6fec3b70a1c commit and layout_paragraphs 2.0.1, in a fresh install, when i select a layout (called section in screencast), default selected layout is offcanvas which has variants.
Bootstrap grid with columns don't have variants.
When i select a bootstrap grid, \Drupal\ui_patterns\Element\ComponentFormBase::getComponent() get component id from default value (offcanvas) instead of selected #component_id ( bootstrap grid_row_2).
/**
* Helper function to return the component.
*/
protected static function getComponent(array $element): Component | NULL {
$component_id = $element['#default_value']['component_id'] ?? $element['#component_id'] ?? NULL;
/** @var \Drupal\Core\Theme\ComponentPluginManager $component_plugin_manager */
$component_plugin_manager = \Drupal::service("plugin.manager.sdc");
return $component_id ? $component_plugin_manager->find($component_id) : NULL;
}
Causes :
TypeError: Drupal\ui_patterns\Element\ComponentFormBase::getSources(): Argument #2 ($definition) must be of type array, null given, called in /var/www/html/web/modules/contrib/ui_patterns/src/Element/ComponentPropForm.php on line 88 in Drupal\ui_patterns\Element\ComponentFormBase::getSources() (line 155 of modules/contrib/ui_patterns/src/Element/ComponentFormBase.php).
Switching the two conditions fixes it, but i don't think this is the right way to do it.
/**
* Helper function to return the component.
*/
protected static function getComponent(array $element): Component | NULL {
$component_id = $element['#component_id'] ?? $element['#default_value']['component_id'] ?? NULL;
/** @var \Drupal\Core\Theme\ComponentPluginManager $component_plugin_manager */
$component_plugin_manager = \Drupal::service("plugin.manager.sdc");
return $component_id ? $component_plugin_manager->find($component_id) : NULL;
}
$definition is NULL because loaded component is the offcanvas component which has variants, but we are trying to get variant prop from grid row component which has no variant in its definition.
Active
2.0
Code