From 6265e21785487da6c398077c79a279b7af31582a Mon Sep 17 00:00:00 2001
From: nod_ <nod_@598310.no-reply.drupal.org>
Date: Tue, 7 Jan 2025 10:18:00 +0100
Subject: [PATCH] Issue #3098960 by pbonnefoi, godotislate, schaefdi, nod_,
 arunkumark, smustgrave, candalt: Nested paragraphs with same field name are
 ordered wrong

---
 core/includes/theme.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 38c01e5cc7b7..f5c1d3905f6e 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -1462,7 +1462,8 @@ function template_preprocess_field_multiple_value_form(&$variables): void {
 
   if ($variables['multiple']) {
     $table_id = Html::getUniqueId($element['#field_name'] . '_values');
-    $order_class = $element['#field_name'] . '-delta-order';
+    // Using table id allows handing nested content with the same field names.
+    $order_class = $table_id . '-delta-order';
     $header_attributes = new Attribute(['class' => ['label']]);
     if (!empty($element['#required'])) {
       $header_attributes['class'][] = 'js-form-required';
-- 
GitLab