Paragraphs and Entity Browser: Weird behavior while editing a referenced entity in Entity Browser modal

Created on 17 March 2021, almost 4 years ago
Updated 2 January 2024, 12 months ago

Problem/Motivation

There is some weird behavior if you edit a referenced entity in Entity Browser modal.
It's happening in the following situation:

  • The referenced entity has a paragraph field
  • The referenced entity is of the same type as the entity it is referenced in
  • The "paragraphs" field widget is used (formerly and in 8.x-2.5 still called "Experimental")

Now if you edit the referenced entity via the Entity Browser Modal and try to add a paragraph to the referenced entity, this will not happen in the modal but outside in entity that is referencing.

This happens because the ajax wrapper id is not distinct in this case. The same id is there in the outer (normal entity) form and the inner (modal entity) form.

Steps to reproduce

Using a node entity (would be the same for other entities too)

  • Add an entity reference field to a node content type allowing to reference entities of this content type
  • Add a paragraph field to this content type with at least one allowed paragraph type
  • Use the "paragraphs" (formerly "Experimental") widget on the paragraph field
  • Create two nodes of this content type
  • Reference the second node in the first node's entity reference field
  • Edit the second node via the first node. Use the edit button on the entity reference which opens the Entity Browser Modal edit form
  • Add a paragraph to the second node
  • The paragraph will not be added in the second node, but in the first node (outside the Modal)

Proposed resolution

Try to have a unique ajax wrapper id for this case too.

The "entity_reference_paragraphs" (aka Classic) widget does not have this problem. This is because it uses getUniqueId() to create the wrapper id.

The "paragraphs" (aka Experimental) widget does instead use getId() here and it seems for good reason .

So it seems the solution cannot just be to change back to getUniqueId().

Maybe one could add information about the entity the paragraph field is in to the ajax wrapper id, for example add bundle and entity id to the ajax wrapper id.

Remaining tasks

create a patch

User interface changes

none

API changes

none

Data model changes

none

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇩🇪Germany stefan.korn Jossgrund

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

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024