Experimental "Layout Paragraphs Builder" field widget overwrites original language when saving translation

Created on 28 December 2022, about 2 years ago
Updated 22 October 2024, 2 months ago

Problem/Motivation

Using the Layout Paragraphs Frontend Builder Experimental Field Widget overwrites all translations when you press "Save".

Steps to reproduce

Add a translation for any content type using the frontend builder widget and edit the new translation's Layout Paragraphs field using the frontend builder. Save your changes, then check the source translation, which will have been overwritten by your changes.

Proposed resolution

FIx / text.

Remaining tasks

Needs tests.

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States justin2pin

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Pipeline finished with Success
    2 months ago
    Total: 948s
    #317063
  • Pipeline finished with Success
    2 months ago
    Total: 1000s
    #324979
  • πŸ‡ΊπŸ‡¦Ukraine sickness29

    Added test for front end builder which checks translations management, found also issues with symmetric translation setup, so added fixes as well, please check and let me know if anything

  • First commit to issue fork.
  • πŸ‡³πŸ‡±Netherlands falco010 πŸ‡³πŸ‡± The Netherlands

    Hi @sickness29

    We were getting the following errors after your last commit:
    InvalidArgumentException: Invalid translation language (it) specified. in Drupal\Core\Entity\ContentEntityBase->getTranslation() (line 903 of core/lib/Drupal/Core/Entity/ContentEntityBase.php).
    Drupal\layout_paragraphs\LayoutParagraphsLayout->getEntities() (Line: 275)
    Drupal\layout_paragraphs\LayoutParagraphsLayout->getComponents() (Line: 246)
    Drupal\layout_paragraphs\LayoutParagraphsLayout->getLayoutSection(Object) (Line: 74)
    Drupal\layout_paragraphs\LayoutParagraphsRendererService->renderLayoutSection(Array, Object, 'default') (Line: 273)
    Drupal\layout_paragraphs\Plugin\paragraphs\Behavior\LayoutParagraphsBehavior->view(Array, Object, Object, 'default') (Line: 42)

    So I added a guard for the getTranslation() you added to prevent this error from happening. Whenever a getTranslation() is called it should always be checked if the translations exists by doing a hasTranslation() to prevent the above error.

Production build 0.71.5 2024