saade/filament-adjacency-list

[Bug]: When you move items they disappear

0528Makoto opened this issue · 2 comments

What happened?

You want to change the level of an item or a group

How to reproduce the bug

You have a list of items when you edit the resource, you move the item/group to root or another level

11-09-2023_14-47-31.mp4

Package Version

3.x

PHP Version

8.2.0

Laravel Version

10.22.0

Which operating systems does with happen with?

Linux

Notes

No response

saade commented

Hey, could you update your Livewire and Filament to the latest version and see if the problem persists?
Seems like a LW Dom Diffing issue and should be fixed in newer versions

I have been struggling with this "bug" as well. Updating the packages did not help for me. I don't know if @DevMakoto had the same problem as me but:

The array you pass in as data must have unique keys!
Which, hindsight all my struggles, seems really obvious.

In the above video example when the first item of a level (a.1.1), with a key of 0, is moved to another level, there will be two items with the key of 0.
In this case a.1.1 and a.1.
The for each loop in the 'builder::sort' listener will then override one of the values.
In this case a.1.1 since it is placed above a.1.

Although this is obviously not a bug, it would be really nice if this is in the documentation.

Edit: I have made a pull request to add this to the documentation.