Layout Paragraphs Builder ignores configuration in fields that are configured to allow only one Paragraph item. Even though a field is set up to only allow one Paragraph item, editors can still use the duplicate / move features within Layout Paragraphs Builder.
| Comment | File | Size | Author |
|---|---|---|---|
| Screen Shot 2022-01-26 at 15.51.45.png | 22.55 KB | philip_stier |
Issue fork layout_paragraphs-3260905
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
hudriBy design Layout Paragraphs can not work reasonable with single cardinality field storage:
In order to use Layout Paragraphs, you must have a cardinality of at least 2, one layout paragraph storing the layout behavior, and one content paragraph storing the actual content.
In general, I believe the combined usage of limited field storage cardinality and Layout paragraphs doesn't make sense. When using layout discovery, the sensible amount of children is tied to the number of regions defined in your layout file, and not by the field cardinality setting.
I can see the need to limit the type or number of content paragraphs per layout and/or region, but this limitation can not be done with field storage cardinality. There is a Layout paragraphs restriction module, but this was for version 1 and for limiting by type, not by count. I currently don't know of any module compatible with v2.
If you have the requirement to limit allowed paragraphs with the field storage setting, do not use Layout Paragraphs, they contradict each other by concept.
I think we should add something like "Set the cardinality to unlimited in the field storage setting" in the "Getting started" section of the module page.
Comment #3
justin2pin commented@philip_stier - good catch, this needs to be fixed. I agree with @hudri that the use-case is rare, but field widgets do need to respect cardinality settings regardless. We need to prevent users from adding more paragraphs to a given reference field than is allowed by the cardinality limit set by the site owner.
Comment #5
justin2pin commentedComment #7
justin2pin commentedComment #9
pookmish commentedSomething about the commit in this issue broke the functionality to edit a paragraph within a layout. At this moment I'm not sure what about it broke, but I used git bisect to identify the commit in this issue.
before, I would be able to hover over a paragraph and I would see the ability to edit the paragraph. Now hovering doesn't display anything. I didn't find an existing issue, so I thought I'd start here.
Comment #10
justin2pin commentedThanks @pookmish - Can you list the steps needed to reproduce this? Do your paragraph templates override or change the ID attribute? This commit slightly changed the way controls are stored in JS and attached to paragraphs. The IDs on paragraph containers are now used to correctly match and render the appropriate controls (edit/delete/etc.) for each paragraph using JS.
Comment #11
pookmish commentedRe-tracing my code, I remember I had to do some special work to get the UI functionality working correctly when using UI Patterns module displays on the paragraphs. I noticed that when using a regular paragraph display settings the hover effects work as expected. But when using a paragraph that is configured to use a custom pattern template from UI Patterns, the hover affect breaks.
I'll start by tracing through the special work around I did to see what might be different compared to the previous version.
Is this line the one you are referring to about the ID attribute?
Comment #12
pookmish commentedI found the issue that was happening. At some point, the
idattribute was being changed through the rendering process. If the paragraph was for example 35, the id should be 35. But then through some part of rendering the various layers, it got changed to35--2which obviously broke the hover functionality.Thanks for the help.
Just in case anyone runs into a similar issue.
Here's the snippet of code I use to make UI patterns & the DS module work with LB in the edit screen.
With a template
patterns-use-wrapper-admin.html.twigcontaining:Comment #13
justin2pin commentedThanks again @pookmish. I actually wonder if we should make a feature request to NOT use the ID attribute, for this reason. We initially debated using the ID vs a custom data- attribute, and went with the ID just for simplicity. It seems pretty likely that other sites -- like yours -- might change the ID value, breaking the controls.
Comment #14
pookmish commentedIMO that would be a good move to make. Something like
data-lp-builder-idwould be unique enough and since it would be populated by the entity ID there no chance at conflicts with other paragraphs in the widget. Then you could remove the need forHtml::getUniqueId()which is also a part of the issue for me.