saade / filament-adjacency-list

A Filament package to manage adjacency lists (aka trees).
https://filamentphp.com/plugins/saade-adjacency-list
MIT License
74 stars 13 forks source link

[Bug]: When you move items they disappear #8

Closed 0528Makoto closed 7 months ago

0528Makoto commented 1 year ago

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

https://github.com/saade/filament-adjacency-list/assets/4119035/65a3c050-2829-44ce-ad1e-c0c917cd57f1

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 10 months ago

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

gieter-solutions commented 10 months ago

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.