Nest paragraphs behaviors missing.

Created on 21 May 2023, over 1 year ago
Updated 29 August 2024, 5 months ago

Problem/Motivation

First of all, thank you for all of the work on this module, total game changer.

I have three "top level" or "container" paragraphs: Basic Components, Advanced Components, and Listing Components. These components are referenced from a node field, field_content.

Each top level paragraph contains various child paragraphs components:
Basic Components:
- Heading
- Image
- etc.

The Heading paragraph type has a behavior plugin that allows selecting the heading level, alignment, etc.

However, the behavior form is missing.

I saw in #3229555: Add Paragraph Behaviors Form Support that behaviors were added back to the module, which is awesome, so I was surprised when I couldn't access the behavior form for the Heading component. After playing around, I added the Heading paragraph type to field_content directly, and now I can see the behavior form in the details element.

It would be great if I could access the behavior plugin forms of the nested paragraphs. Nesting the child paragraphs has several advantages:

  • Better organization of the components (instead of a single, long list of every possible component),
  • I have each component defined in separate modules, and nesting the components makes it way easier to install and make available everywhere,
  • and I can add wrappers around components that are grouped together, making it easier for editors to move a group of components.

Steps to reproduce

  1. Create a parent / container paragraph type.
  2. Create a child paragraph type which has a behavior plugin enabled.
  3. Add the child paragraph type to the parent type.
  4. Create a content type with an ERR field referencing the parent paragraph type.
  5. Create a node, add the parent paragraph type, then add the child paragraph type.

Proposed resolution

Admittedly, this is not super easy to solve, if your parent paragraph type has behaviors + the child has behaviors, trying to manage the different forms and maintaining the context could get complicated.

I've been looking at this issue Add paragraphs behaviors action button Needs review . The issue is about a general UX issue with Paragraphs behavior forms (with behaviors toggle button at the top of all the paragraphs, which activates all of the paragraphs behaviors). However, I could see how the solution in the issue could be adapted for the use-case I described.

The idea would be, for top level paragraphs, if there is an active behavior plugin, continue to use the details element for the subform. But for each nested paragraph type with an active behavior plugin, add a button to the paragraph that would toggle the behavior form for just that paragraph.

Remaining tasks

I am going to look into this more to see what the best possible approach is. I've tested just the code from Add paragraphs behaviors action button Needs review , but it doesn't seem to work, maybe I am just missing something, but when I click the button, it just redirects to a paragraphs edit page.

User interface changes

New button on child paragraphs.

API changes

Not sure yet

Data model changes

One thing we might want to do to keep this new feature consistent is add a configuration for the button label.

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States scottsawyer Atlanta

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @scottsawyer
  • 🇺🇸United States scottsawyer Atlanta

    You know what, I just implemented this in my own module, so right now, I don't think I need this feature baked into this module, per se. However, I'll leave the issue open and see if anyone else is interested.

  • 🇫🇷France nicolasgraph Strasbourg

    I had the same issue with nested paragraphs which used the paragraphs stable widget.
    One of the solution is to also use the layout paragraphs widget for these nested paragraphs ; it offers a quite nice ux and allows to edit behaviors settings.

Production build 0.71.5 2024