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
- Create a parent / container paragraph type.
- Create a child paragraph type which has a behavior plugin enabled.
- Add the child paragraph type to the parent type.
- Create a content type with an ERR field referencing the parent paragraph type.
- 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.