scottdurow / power-drag-drop

MIT License
132 stars 29 forks source link

Updating gallery items reset the drag&drop zones inside #45

Closed kennethdeman closed 1 year ago

kennethdeman commented 1 year ago

Whenever I update the collection that is the item source of the gallery wherein the drag&drop zones are found, the drag&drop items are flung back to the master zone. Is this normal behaviour? And if so, how can I prevent this?

Thanks!

kennethdeman commented 1 year ago

Found out you simply have to patch the items (in the collection you used for it) after the OnDrop event and set their Zone to the DropZoneId of the current zone they are in.

Like this:

ForAll(
    Filter(DragDropControl.CurrentItems, HasMovedZone=true) As DragDropItem,

    Patch(collection,
        LookUp(collection, 'id' = DragDropItem.ItemId),
        {
            Zone: DragDropItem.DropZoneId
        }
    );
)

A gallery reset will cause them to fall back on the zone assigned in the collection (their starting zone basically).