diff -u b/js/paragraphs.admin.js b/js/paragraphs.admin.js --- b/js/paragraphs.admin.js +++ b/js/paragraphs.admin.js @@ -9,19 +9,30 @@ */ Drupal.behaviors.bodyTabs = { attach: function (context, settings) { - /** Set content fields to visible when tabs are created **/ - $('.paragraphs-content').show(); - $('.paragraphs-behavior').hide(); - /** Create click event **/ + /** 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')) { + $('.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'))) { + $(context).find('.paragraphs-tabs').find('#content').addClass('is-active'); + } + $('.paragraphs-content').show(); + $('.paragraphs-behavior').hide(); + } + /** Create click event. **/ $(context).find('.paragraphs-tabs').find('a').click(function(e) { e.preventDefault(); - /** Switching active class between tabs */ + /** Switching active class between tabs. */ var el = jQuery(this); $(context).find('.paragraphs-tabs').find('li').removeClass('is-active'); el.parent('li').addClass('is-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 */ + /** Show/Hide fields based on current active class. */ if($(context).find('.paragraphs-tabs-wrapper').find('#content').hasClass('is-active')) { $('.paragraphs-content').show(); $('.paragraphs-behavior').hide(); 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 @@ -824,7 +824,7 @@ // the perspective tabs. $field_prefix = strtr($this->fieldIdPrefix, '_', '-'); if ($max > 0 && $items->getEntity()->getEntityTypeId() != 'paragraph') { - $tabs = '
'; + $tabs = ''; } else { $form['#attributes']['class'][] = 'paragraphs-nested';