The problem is due to the cloneItems method. When the properties are copied from the source to the destination we don't take into account any properties existing only on the destination.
So what happens is this:
Grid initializes, auto size attribute is applied to items.
Snapshot.
Drag and drop. At this point the order of the items might have changed.
Snapshot is copied back. Now the auto size attribute may be copied to the wrong items.
Multiple items end up with the auto size attribute.
Resize -> items end up being stretched.
A solution is to clear the extra properties on the destination. We can do this by doing two iterations over the properties:
once on the source where we copy them over the destination,
once on the destination where we copy them from the source.
The second time will set any extra properties to undefined since they won't be on the source object.
Another solution is to ignore the auto size attribute when copying the properties since it's the only extra property that we add onto the items.
Solution
The problem is due to the cloneItems method. When the properties are copied from the source to the destination we don't take into account any properties existing only on the destination.
So what happens is this:
A solution is to clear the extra properties on the destination. We can do this by doing two iterations over the properties:
The second time will set any extra properties to
undefined
since they won't be on the source object.Another solution is to ignore the auto size attribute when copying the properties since it's the only extra property that we add onto the items.