diff -u b/js/paragraphs.admin.js b/js/paragraphs.admin.js --- b/js/paragraphs.admin.js +++ b/js/paragraphs.admin.js @@ -11,14 +11,19 @@ attach: function (context, settings) { /** Set content fields to visible when tabs are created. After an action being performed, stay on the same * perspective. **/ - if($(context).find('.paragraphs-tabs-wrapper').find('#behavior').hasClass('is-active')) { + if($(context).find('.layout-region-node-main').hasClass('behavior-active')) { + $(context).find('.layout-region-node-main').removeClass('content-active'); + $(context).find('.layout-region-node-main').addClass('behavior-active'); + $(context).find('.paragraphs-tabs').find('#content').removeClass('is-active'); + $(context).find('.paragraphs-tabs').find('#behavior').addClass('is-active'); $('.paragraphs-content').hide(); $('.paragraphs-behavior').show(); } else { /** Activate content tab visually if there is no previously activated tab. */ - if (!($(context).find('.paragraphs-tabs-wrapper').find('#content').hasClass('is-active'))) { + if (!($(context).find('.layout-region-node-main').hasClass('content-active')) && !($(context).find('.layout-region-node-main').hasClass('behavior-active'))) { $(context).find('.paragraphs-tabs').find('#content').addClass('is-active'); + $(context).find('.layout-region-node-main').addClass('content-active'); } $('.paragraphs-content').show(); $('.paragraphs-behavior').hide(); @@ -30,14 +35,18 @@ var el = jQuery(this); $(context).find('.paragraphs-tabs').find('li').removeClass('is-active'); el.parent('li').addClass('is-active'); + $(context).find('.layout-region-node-main').removeClass('behavior-active'); + $(context).find('.layout-region-node-main').removeClass('content-active'); $(context).find('.paragraphs-tabs-wrapper').removeClass('is-active'); $(context).find(el.attr('href')).addClass('is-active'); /** Show/Hide fields based on current active class. */ if($(context).find('.paragraphs-tabs-wrapper').find('#content').hasClass('is-active')) { + $(context).find('.layout-region-node-main').addClass('content-active'); $('.paragraphs-content').show(); $('.paragraphs-behavior').hide(); } if($(context).find('.paragraphs-tabs-wrapper').find('#behavior').hasClass('is-active')) { + $(context).find('.layout-region-node-main').addClass('behavior-active'); $('.paragraphs-content').hide(); $('.paragraphs-behavior').show(); } diff -u b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php --- b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php +++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php @@ -1318,7 +1318,7 @@ } if (isset($element[$delta]) && isset($element[$delta]['behavior_plugins'][$plugin_id]) && $form_state->getCompleteForm()) { $subform_state = SubformState::createForSubform($element[$delta]['behavior_plugins'][$plugin_id], $form_state->getCompleteForm(), $form_state); - if ($item['behavior_plugins'][$plugin_id]) { + if (isset($item['behavior_plugins'][$plugin_id])) { $plugin_values->submitBehaviorForm($paragraphs_entity, $item['behavior_plugins'][$plugin_id], $subform_state); } } reverted: --- b/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php +++ a/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php @@ -75,13 +75,13 @@ // Create a node with a Paragraph. $this->drupalGet('node/add/paragraphed_test'); + $this->assertFieldByName('field_paragraphs[0][behavior_plugins][test_text_color][text_color]', 'green'); - $this->assertFieldByName('field_paragraphs[0][subform][test_text_color][text_color]', 'green'); // Setting a not allowed value in the text color plugin text field. $plugin_text = 'green'; $edit = [ 'title[0][value]' => 'paragraphs_plugins_test', 'field_paragraphs[0][subform][field_text][0][value]' => 'amazing_plugin_test', + 'field_paragraphs[0][behavior_plugins][test_text_color][text_color]' => $plugin_text, - 'field_paragraphs[0][subform][test_text_color][text_color]' => $plugin_text, ]; $this->drupalPostForm(NULL, $edit, t('Save and publish')); // Asserting that the error message is shown. @@ -89,7 +89,7 @@ // Updating the text color to an allowed value. $plugin_text = 'red'; $edit = [ + 'field_paragraphs[0][behavior_plugins][test_text_color][text_color]' => $plugin_text, - 'field_paragraphs[0][subform][test_text_color][text_color]' => $plugin_text, ]; $this->drupalPostForm(NULL, $edit, t('Save and publish')); // Assert that the class has been added to the element. @@ -97,21 +97,21 @@ $this->clickLink('Edit'); // Assert the plugin fields populate the stored values. + $this->assertFieldByName('field_paragraphs[0][behavior_plugins][test_text_color][text_color]', $plugin_text); - $this->assertFieldByName('field_paragraphs[0][subform][test_text_color][text_color]', $plugin_text); // Update the value of both plugins. $updated_text = 'blue'; $edit = [ + 'field_paragraphs[0][behavior_plugins][test_text_color][text_color]' => $updated_text, + 'field_paragraphs[0][behavior_plugins][test_bold_text][bold_text]' => TRUE, - 'field_paragraphs[0][subform][test_text_color][text_color]' => $updated_text, - 'field_paragraphs[0][subform][test_bold_text][bold_text]' => TRUE, ]; $this->drupalPostForm(NULL, $edit, t('Save and keep published')); $this->assertNoRaw('class="red_plugin_text'); $this->assertRaw('class="blue_plugin_text bold_plugin_text'); $this->clickLink('Edit'); // Assert the plugin fields populate the stored values. + $this->assertFieldByName('field_paragraphs[0][behavior_plugins][test_text_color][text_color]', $updated_text); + $this->assertFieldByName('field_paragraphs[0][behavior_plugins][test_bold_text][bold_text]', TRUE); - $this->assertFieldByName('field_paragraphs[0][subform][test_text_color][text_color]', $updated_text); - $this->assertFieldByName('field_paragraphs[0][subform][test_bold_text][bold_text]', TRUE); // Test plugin applicability. Add a paragraph type. $paragraph_type = 'text_paragraph_test'; diff -u b/tests/src/FunctionalJavascript/ParagraphsExperimentalEditPerspectivesUiTest.php b/tests/src/FunctionalJavascript/ParagraphsExperimentalEditPerspectivesUiTest.php --- b/tests/src/FunctionalJavascript/ParagraphsExperimentalEditPerspectivesUiTest.php +++ b/tests/src/FunctionalJavascript/ParagraphsExperimentalEditPerspectivesUiTest.php @@ -25,11 +25,13 @@ */ public static $modules = [ 'node', + 'paragraphs_collection', 'paragraphs_collection_test', - 'paragraphs_test', + 'paragraphs_collection_demo', 'field', 'field_ui', 'block', + 'link', ]; /** @@ -46,12 +48,16 @@ - $this->loginAsAdmin(); + $this->loginAsAdmin([ + 'access content overview', + 'edit any paragraphed_content_demo content' + ]); $page = $this->getSession()->getPage(); - $this->drupalGet('node/2/edit');; + $this->drupalGet('node/3/edit'); $this->clickLink('Behavior'); - $style_selector = $page->find('css', 'js-form-item-field-paragraphs-demo-0-behavior-plugins-style-style form-item-field-paragraphs-demo-0-behavior-plugins-style-style'); + $style_selector = $page->find('css', '.js-form-item-field-paragraphs-demo-1-behavior-plugins-grid-layout-layout'); $this->assertTrue($style_selector->isVisible()); $this->clickLink('Content'); $this->assertFalse($style_selector->isVisible()); } + }