- πΊπΈUnited States greenskin
The patch only fixes the issue when the paragraph is contained within a region, not when the paragraph is the root element for the entity reference field. Confirmed patch needs work.
- πΊπΈUnited States asherry
I did a lot of debugging on this. I don't know if I would consider it regression, in that ComponentFormBase is completely new and not used in version 1. The issue is triggered when two entity forms, (not sub entity forms), have the same field name, but I believe that the fix for this is in the media library module itself.
I wrote up a ticket in core about this. Although this is technically a contrib issue, I don't see any way of being able to fix it in a contrib context. This is going to be a problem, (and I tested it out), with other contrib modules implementing similar entity form design.
https://www.drupal.org/project/drupal/issues/3345064#comment-14945590 π Media library field_widget_id is not unique enough Needs work
- πΊπΈUnited States asherry
In my opinion this ticket should be moved to "closed (works as designed)".
- Status changed to Postponed
over 1 year ago 8:12am 24 March 2023 - π©πͺGermany Anybody Porta Westfalica
I think we should postpone it on π Media library field_widget_id is not unique enough Needs work . Perhaps it makes sense to add tests here, to ensure it can't happen again?
- πΊπΈUnited States azinck
I don't believe this issue is limited to media fields. I'm seeing the same behavior with paragraph fields. I have the following structure:
Content type with these fields:
- field_paragraphs - entity reference revisions field using the Paragraphs (stable) widget
- field_wide_content - entity reference revisions field using the Layout Paragraphs widget
Then I have a paragraph type called a "Summary Box" with the following field:
- field_paragraphs - entity reference revisions field using the Paragraphs (stable) widget
If I add a Summary box paragraph to field_wide_content, and then try to add a paragraph into that paragraph's field_paragraphs field I don't see the new paragraph added there in the modal. But if I close the modal I can see it got added to the field_paragraphs field on the parent node instead. If I then re-open the modal to edit my Summary box paragraph I see the paragraph I added earlier (yes, the same paragraph is now in 2 places). Furthermore, edits to content in the node's field_paragraphs field are reflected in the Summary box paragraph's field_paragraphs field. This is on Layout Paragraphs 2.0.2 and Drupal 9.5.7.
- πΊπΈUnited States azinck
I'm very happy to say that the bug I noted in #12 seems to be resolved by the MR on this issue!
- Status changed to Needs work
over 1 year ago 7:38am 23 May 2023 - π¦πΉAustria hudri Austria
Given the observation in #12 this does not seem to be a media library (or media library only) issue, so changing back to needs work.
- πΊπΈUnited States asherry
@azinck, thanks for the example. It looks like this is in fact not only a media library issue, but it is an issue with widgets that aren't using unique enough IDs to replace content on ajax calls.
- @azinck, in your example the actual widget that's doing the ajax replace is the paragraphs stable widget
- I see there is an issue here π Paragraphs and Entity Browser: Weird behavior while editing a referenced entity in Entity Browser modal Needs review , and in the issue they mention that "getUniqueId" should work, but I don't believe that's true. There is likely an issue with the paragraps widgets when there are multiple instances
- These other widget issues are popping up because layout paragraphs, (and other modules), are modules that embed multiple forms on the page, and the ajax calls were never equipped to distinguish.
- The MR for this issue might work in some cases, but it's not the solution. The paragraphs component form is a base form, it can't use #parents because it doesn't have any, and will break other instances.
- The issue really centers around widgets that are relying on field names, and layout paragraphs isn't. All the ajax functionality is using uuids.
- π©πͺGermany Anybody Porta Westfalica
As of #16 setting priority to major. At least it sounds it can be solved? And reproduced in a test?
Do we think it should be a core job to provide and ensure the unique IDs or should each module do? (At least a core issue might need a long time to be finished, I guess - so it might make sense to create a core issue AND solve it here?)
- πΊπΈUnited States asherry
This isn't major, it only happens in very specific cases. It also can't be fixed here. The current patch, as already mentioned in #8, only works for instances that are in regions, and it is still breaking tests. The root of the issue is in the ajax calls made by the widgets that are actually replacing the HTML.
I already linked to a fix that works for media library. I understand that there are issues with other widgets, like media browser, and the paragraphs stable widget. I'd be great if people can submit a patch to those modules and link them here.
- Status changed to Closed: works as designed
over 1 year ago 7:36pm 24 May 2023 - πΊπΈUnited States justin2pin
Setting this to "Closed (works as designed)" per comments #18, #16, and #10. Thanks all.
- π¦πΉAustria hudri Austria
This patch here does not work well with paragraph behavior subforms. Better use the linked drupal/core patch #3345064 π Media library field_widget_id is not unique enough Needs work which fixes the media library issue, and nested behavior plugins (inside LP component forms) keep working.