Form state errors break nested layout paragraphs dialog

Created on 9 May 2023, about 1 year ago
Updated 21 June 2024, 6 days ago

Problem/Motivation

Hello,

When I save a nested layout paragraph with empty required field, required error appear but after fill the field, the dialog is broken and opens in full page on page url : /layout-paragraphs-builder/[Nested-paragraph-uuid]/choose-component
=> This makes it impossible to save the paragraph because the link with the created content is broken. (See attachment)

I don't found any issue about this !?

Steps to reproduce

1. Install a new D9.5 base (Think D10 have the same problem)
2. Create one content type "Example"
3. Create two paragraph types "First" / "Nested"
4. Add required "Title" text field to "Nested" paragraph type
5. Add field reference to "Nested" paragraph type in "First" paragraph type and use "Layout paragraphs" for form display
6. Add field reference to "First" paragraph type in "Example" content type and use "Layout paragraphs" for form display
7. Add an "Example" content, add "First" paragraph, add "Nested" paragraph, submit form without fill title field
=> Error message "Title is required" appear, this is OK but if we fill the field "Title" and re-submit, form redirects to url : /layout-paragraphs-builder/[Nested-paragraph-uuid]/choose-component => We lost the contribution of "Example" content !!

Proposed resolution

It's look like an ajax submit doesn't want to work ?
It would be necessary to analyze and create a patch in first time.

Thank you in advance for your helping.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @El Pollo
  • Has anyone encountered the same problem ?

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    I've ran into some oddities with the module, I think this was one of them.

  • πŸ‡΅πŸ‡ΉPortugal lolgm

    I have the same problem.

    After investigating a little, I noticed that when the validation messages for the mandatory fields of the form are shown, all open dialogs (level 1 and level 2) are replaced with the form that gave an error, which means that all open dialogs have the same content.

    It seems to me that this problem is happening due to some problem updating the dialogs/forms with AJAX.
    However, I was unable to identify the origin of this problem.

  • πŸ‡³πŸ‡±Netherlands erwinvb

    I'm having the same issue with nested paragraphs.

    For example our paragraphs are filled with the content below:

    1. Text
    2. Media
    3. Collapse (content with paragraphs)
      1. Text
      2. Media

    Steps to reproduce:

    1. Edit collapse
    2. Opens first dialog with layout paragraphs
    3. Edit text inside the collapse
    4. Opens second dialog on top of the first one with the text editor
    5. Try to submit without a body (body is required)
    6. Will show a validation error after Drupal updates the modals via Ajax
    7. Result: Modal 1 and Modal 2 contains the form of the nested text paragraph with the validation error
    8. After submitting Modal 2 with the required body, it can not reference to modal 1 since this modal/form is also replaced with the form with validation errors
  • πŸ‡¦πŸ‡ΉAustria hudri Austria

    @erwinvb For media entities, use the patch from https://www.drupal.org/project/drupal/issues/3345064 πŸ› Media library field_widget_id is not unique enough Needs work

  • πŸ‡¬πŸ‡§United Kingdom johntarling

    Hit this issue too when creating a tabbed content component in D10.2 with Layout paragraphs 2.04.

  • Currently experiencing the same issue on Drupal 10.2.4 and layout_paragraphs 2.0.4

  • Status changed to Needs review 3 months ago
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 3 months ago
    55 pass
  • πŸ‡²πŸ‡©Moldova marjina-constantin

    Here is a patch with a fix.

    As @erwinvb mentioned, the problem is that nested dialogs have the same data-drupal-selector attribute. Current patch adds also paragraph bundle to the attribute, to make it more unique. It will probably work for most cases, except when for some reason we have the same paragraph form opened in nested dialogs. This case will require each dialog to know how deep in the nesting level it is.

    Current patch is a quick fix for the most people :)

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Just ran into the same issue. I agree this is major and still existing in latest release.

Production build 0.69.0 2024