vue-draggable-next icon indicating copy to clipboard operation
vue-draggable-next copied to clipboard

Duplicates during sorts

Open Brand3000 opened this issue 1 year ago • 2 comments

Hello! I use Laravel Nova with the outl1ne/nova-sortable package for having the ability to sort items. When I try to drag an item down, it duplicates. Actually, this problem was noticed by several developers. Look this issue please.

I dug into the core and realised that there's an issue especially with vue-draggable-next.

If the keys like so:

service-resource-items-0
service-resource-items-1
service-resource-items-2
...

everything works fine

However, if the keys like so:

service-resource-items-0-1
service-resource-items-1-2
service-resource-items-2-3
...

the issue happens.

A piece of the source code:

<draggable
        tag="tbody"
        v-model="fakeResources"
        draggable="tr"
        @update="updateOrder"
      >
        <ResourceTableRow
          v-for="(resource, index) in fakeResources"
          :key="`${resourceName}-items-${index}-${resource.id.value}`"
        />
 </draggable>

If I delete the "-${resource.id.value}" part from the :key attribute, sorting works fine.

Brand3000 avatar Nov 10 '23 10:11 Brand3000

@Brand3000 can you please provide reproduction repo ?

anish2690 avatar Dec 04 '23 21:12 anish2690

@Brand3000 can you please provide reproduction repo ?

Look into this thread please https://github.com/outl1ne/nova-sortable/issues/192

Brand3000 avatar Dec 05 '23 08:12 Brand3000