My purpose to implement dragging elements from one list to another, example:
- Dragging layout2 element (has 2 nested blocks) into editor.
- Dragging paragraph into the one of two layout blocks.
The issue that I faced up is the layout block doesn’t save any element inside itself. When dragging layout block into Editor is everything okey but if dragging paragraph into layout block, as I expected its appear there is but its not.
Please check the link with source code: https://stackblitz.com/edit/stackblitz-starters-dwd2dm?file=src%2FApp.tsx
One possible reason for this behavior could be related to how you're updating the state when dropping elements into the layout block. In the Layout6 component, when you're updating the state after dropping elements into the layout block, you're concatenating the new list with the existing content:
Instead of directly concatenating the lists ([...item.content, ...newList]), try setting the content directly to the new list:
By doing this, the content of the layout block will be replaced by the dropped elements rather than appended to the existing content.
I tried replacing L98 - L104 with my code, and I feel it works as it doesn't repeat/misinterprete dragged components into layout.
Appended
Replace Layout2 and Layout6 with the following code to check if it works. I tried replacing them with this code, and now drag to Layout2 and Layout6 work fine.