Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On the site I encountered this issue I have nested paragraph fields. I added a few paragraphs, switched to drag and drop mode and saved the host entity. This lead to deletion of existing paragraphs referenced in the same paragraphs fields where I added new ones.
Comments
Comment #2
miro_dietikerHappened to us once as well. Still not reproducible.
But what can be reproduced is that dragging + save does not save (as it should). Instead you first need to click the button to close the drag & drop mode.
Comment #3
Lukas von BlarerI am able to easily reproduce my issue. The issue is on a existing node with paragraphs nested three levels deep.
Steps to reproduce:
After that the values of the fields i mixed up pretty randomly.
Comment #4
BerdirThanks for the steps, will look into it.
If you want to be extra helpful, you could add a test method to the DragDrop test, we have fairly similar things alread in there just not yet with new paragraphs. Might result in me looking into this earlier :)
Comment #5
Lukas von BlarerI'm sorry, but I can't do that in the coming weeks…
Comment #6
miro_dietikerWe still experience these problems, especially if you combined delete and add operations with drag & drop.
Best would be to expand test coverage and proof the bug.
Comment #7
zainulhassan4 CreditAttribution: zainulhassan4 commentedCame across it today. Further info, in case someone handles it before my company gets to it:
Using Paragraph Experimental Widgets:
Configuration:
Replicate:
Other details:
bug happens in multiple scenarios, one's mentioned above. Inner box can take in leaf level paragraphs, just not anything above it. so the reason category disappears is because they have leaf under them. However, if you move the single leaf they move around fine.
This does not happen if you avoid creating a box within a box. I dont think its the paragraph itself that matters but the entity reference field inside it probably causes recursion or similar issue on field type.
Note: haven't checked the coding yet, the above is only from observations.
Comment #8
cainaruI ran into this last week as well, with similar steps as #3.
Comment #9
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedI am not sure if this case was mentioned but I'll put it here:
Steps to reproduce:
Demo:
I was testing with paragraphs 8.x-1.x (bac92b0) and entity_reference_revisions 8.x-1.x (167be1c).
This could be a problem in ERR and if so I will link the related issue when I find it.
Comment #10
miro_dietikerOur base library sortable.js seems to have some related glitches. We switched version(s) over the time.
For investigation, please first try to:
* Update sortable to the latest version
* Try a downgrade to our used previous versions
And then please report if switching sortable.js helped to fix your issue.
Comment #11
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedI can confirm #9 is related to SortableJs library that Drag & Drop requires.
https://github.com/SortableJS/Sortable/commit/5602256 is the actual commit that causes the issue described in #9.
Comment #12
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedTo prevent the confusion (and until we fix SortableJs issues) I filled an issue #3056898: Revert the readme to suggest SortableJs 1.6.0 library + patch in Paragraphs to update the Readme.txt file and suggest the older version of the library.
Comment #13
miro_dietikerInteresting..
I see that the commit referred added a new parameter to _dispatchEvent:
NEW
OLD
While the event itself has a new attribute there could be two problems:
a) There is still an outdated call without updated arguments
b) If i remember right, we missed access to some context (toEl?) and thus did a workaround. After they now added the missing context and fixed the old argument, our workaround expectations could be wrong.
Needs investigation. :-)
Comment #14
Martijn de Witin the new RC3 version there is a lot of new code / rewrite. https://github.com/SortableJS/Sortable/commit/854fed779876074d564c053afb...
Maybe it is providing a solution?
Comment #15
jasa CreditAttribution: jasa at Introbay commentedI have just downgraded SortableJS version to 1.6.0. It works as expected!
In the new RC3 there is no fixing for this, just tried it.
Comment #16
stillworks CreditAttribution: stillworks commentedHi agree with jasa, drag and drop works with 1.6.0 but has some wired behavior while dragging in browsers. Newer version is more preceise with this, dragging works but not between nested child/parent paragraphs. We need a fix for this.
Comment #17
BerdirOn #9, two additional notes that are useful when debugging this:
a) Instead of saving directly, you can press "Complete Drag & Drop", which will "only" result in a php exception about invalid hierachies. Easier to test without actually losing the content.
b) To see what's going on, in \Drupal\paragraphs\Plugin\Field\FieldWidget\ParagraphsWidget::buildNestedParagraphsFoDragDrop(), change the hidden _path and _weight fields to type textfield, then you can see in the browser how they change when you move things around.
Note sure if there are other issues, but one thing you can see is that the weight isn't properly recalculated on lower paragraphs if a you move a paragraph down into the nested paragraph. Easy to see on the default node that we create.
Comment #18
sasanikolic CreditAttribution: sasanikolic commentedI tracked down the issue to be in the handleReorder() function. $srcChildren and $children variables were pointing to the same DOM element, which resulted in the parent element not updating its weight and paths with the updateWeightsAndPath() function.
I simplified the function to update the weights of the initial and ending paragraphs nesting level.
I used the most recent version Sortable.js while debugging this (1.10.1). If confirmed, we can delete the required sortable version from the Readme (issue posted above).
Do we already have some related tests that we can update?
Comment #19
miro_dietikerExciting!
Could you please update the readme to drop our compatibility Remarks as well. I read even there is some inconsistency currently..
Comment #20
sasanikolic CreditAttribution: sasanikolic commentedRemoved the 1.6 version requirement from the README.
Comment #21
Berdirguess the inconsistency that they mentioned is that apparently, above this there is text that recommends 1.8 and then below we recommended 1.6 ;)
Since we didn't test < 1.10 now should we update that to recommend using that version?
Comment #22
sasanikolic CreditAttribution: sasanikolic commentedHere is an improved README change with the suggested change. Does this make sense or should we explicitly state which versions cause troubles with nested drag&drop?
Comment #23
miro_dietikerLooks fine. The readme should provide simple information about the current status with recommended versions relevant for the future, not history. If they want to go back in time they can check commit annotations and history.
Soo ready because we commit compatibility with latest sortable without (additional tests)...
Or needs work because we are willing to wait for tests.
Not sure for how much test coverage in drag & drop we should go and how much time it will take. Opinions?
Comment #24
BerdirWe can't add test coverage yet anyway, or only with a custom drupalci.yml that installs it and I don't want to go there as it would be hard to keep that in sync then.
Created #3090457: Use sortable library from core. Committing and updating issue title to explain what we actually did here.