Allow to drag and drop nested paragraphs

Created on 13 November 2023, 8 months ago
Updated 8 December 2023, 7 months ago

Steps to reproduce

Create nested paragraphs: for example accordion and accordion item. User should be allowed to add accordion item inside accordion.
Configure layout paragraph, allow to add accordion paragraph.
Use Paragraphs (stable) widget to display accordion items (default widget).

Visit node where layout paragraph is configured.
Add accordion paragraph with a few accordion items.

Click on "Drag & drop" link in the right corner.
Move some items, click on "Complete drag & drop".

System generates the following error:
Error: Call to undefined method Drupal\layout_paragraphs\Form\EditComponentForm::getEntity() in Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget::reorderParagraphs() (line 2116 of /app/web/modules/contrib/paragraphs/src/Plugin/Field/FieldWidget/ParagraphsWidget.php).

Proposed resolution

ParagraphsWidget expects that getFormObjecjt is a EntityForm and has getEntity() method
rename getParagraph to getEntity() in ComponentFormInterface

This can break some customisation but i do not see any other way.

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡΅πŸ‡±Poland alorenc Wolsztyn, πŸ‡΅πŸ‡±

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

Comments & Activities

  • Issue created by @alorenc
  • πŸ‡΅πŸ‡±Poland alorenc Wolsztyn, πŸ‡΅πŸ‡±
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 8 months ago
    55 pass
  • @alorenc opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review 8 months ago
  • πŸ‡΅πŸ‡±Poland alorenc Wolsztyn, πŸ‡΅πŸ‡±
  • Status changed to RTBC 7 months ago
  • πŸ‡¬πŸ‡·Greece idimopoulos

    A but more precise with this:
    I am defining 3 paragraphs. 1 for a single layout, 1 for the accordion, 1 for the accordion item.
    Then I have in the entity a paragraphs revision for the paragraphs which is using layout builder.
    Then I have the 1 column layout use the stable paragraphs.
    And that is how it is indeed the problem is reproduced. The patch fixes the issue. +1 RTBC. Tested in vanilla Drupal

  • Status changed to Needs work 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States justin2pin

    Thanks for the MR - it sounds like this will work for users running into this specific issue, and passes tests.

    I think we should probably think through this issue a little more though and consider changing LP form classes to use the EntityForm interface. Obviously this would change the API, so needs a little more consideration. Perhaps we can implement EntityFormInterface ComponentFormInterface for backwards compatibility.

    Marking as needs work so we can continue to work on the issue.

Production build 0.69.0 2024