Cloning nested paragraph creates shared child reference

Created on 4 March 2025, 6 months ago

Problem/Motivation

On a new node creation, when cloning a paragraph containing nested paragraph child(s), the original and cloned paragraphs point to the same child entity after the node save.

Steps to reproduce

1. Go to https://simplytest.me
2. Launch a site using Paragraphs 8.x-1.x-dev
3. Create 2 new paragraph types, a) Text containing a text field and b) Section containing a paragraph reference field of Text
4. Update the Basic page content type to contain a Content field that's a paragraph reference field of Section
5. Add a new Basic page
6. Add some text to the first Section > Text, e.g. "Hello World"
7. Now click on the "..." of the Section and click "Duplicate"
8. Update the text of cloned Section > Text to something else, e.g. "Hello World2"
9. Save the node
10. Both text will display "Hello World2"

Proposed resolution

In this issue: https://www.drupal.org/project/paragraphs/issues/3495373 📌 Support duplicate hook Active
A new condition !$item->entity->isNew() was introduced to prevent nested paragraphs from being cloned in this scenario. However, I'm uncertain about the original intent behind this change, so I can't suggest a solution at this stage.

🐛 Bug report
Status

Active

Version

1.19

Component

Code

Created by

🇹🇼Taiwan peterwcm

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024