Problem/Motivation
The behaviors tabbed interface generated by this code
if ($('.paragraphs-tabs-wrapper', context).length > 0) {
$topLevelParWidgets.each(function() {
debugger;
var $parWidget = $(this);
var $parTabs = $parWidget.find('.paragraphs-tabs');
var $parContent = $parWidget.find('.paragraphs-content');
var $parBehavior = $parWidget.find('.paragraphs-behavior');
var $mainRegion = $parWidget.find('.layout-region-node-main');
setUpTab($parWidget, $parTabs, $parContent, $parBehavior, $mainRegion);
});
}
Won't work on inline blocks (i.e. on the context of layout builder due to the absence of .paragraphs-tabs.
This is because this code is failing
$field_prefix = strtr($this->fieldIdPrefix, '_', '-');
if (count($this->fieldParents) == 0) {
if ($items->getEntity()->getEntityTypeId() != 'paragraph') {
$tabs = '<ul class="paragraphs-tabs tabs primary tabs--secondary paragraphs-tabs-hide clearfix"><li class="tabs__tab paragraphs_content_tab"><a href="#' . $field_prefix . '-values" class="tabs__link">' . $this->t('Content', [], ['context' => 'paragraphs']) . '</a></li><li class="tabs__tab paragraphs_behavior_tab"><a href="#' . $field_prefix . '-values" class="tabs__link">' . $this->t('Behavior', [], ['context' => 'paragraphs']) . '</a></li></ul>';
}
}
if (count($this->fieldParents) > 0) {
if ($items->getEntity()->getEntityTypeId() === 'paragraph') {
$form['#attributes']['class'][] = 'paragraphs-nested';
}
}
As it will wrongly identify as a nested paragraph what is in reality a paragraphs field inside a subform (that's why its parents are present).
Steps to reproduce
- Create a paragraph field with behaviors on a block
- Use the block as a inline block on layout builder
- See no interface for switching between Content and Behaviors
Proposed resolution
Reinforce the "nested paragraphs" check by excluding the known inline block structure (more hacky) or inferring by other means that the nesting is actually a paragraph nesting and not other byproduct of drupal Form API extravaganzas.
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Issue fork paragraphs-3606450
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
idiaz.ronceroComment #4
idiaz.ronceroComment #5
idiaz.roncero