Problem/Motivation
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.
| Comment | File | Size | Author |
|---|---|---|---|
| ui_patterns_layout_paragraphs_default_component.mp4 | 5.3 MB | goz |
Issue fork ui_patterns-3520236
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 commentedComment #4
goz commentedComment #5
pdureau commentedMikael did most of ComponentFormBase so he will be the most suited for the review
Comment #6
pdureau commentedComment #8
just_like_good_vibesi am still hesitant because the bug seems triggered by the usage of ui_patterns_ui, and we are trying to fix it in ui_patterns.
Comment #9
pdureau commentedComment #10
pdureau commentedComment #11
just_like_good_vibesi found this line in ui_patterns_ui (UiPComponentFormDisplaysForm)
and we have this line in ui_patterns (ComponentFormBase)
we need to sort this out
Comment #12
just_like_good_vibesComment #14
just_like_good_vibes