sortablejs-vue3 icon indicating copy to clipboard operation
sortablejs-vue3 copied to clipboard

Events should also return the element

Open MickL opened this issue 1 year ago • 2 comments

Hello,

within the events I need to know the id of my element, but I cant access the element:

<Sortable
  :list="elements"
  item-key="id"
  @end="(event: Sortable.SortableEvent) => changeOrder(element.id, event.oldIndex, event.newIndex)"
>
...

This is because I need to know which item exactly has changed because possibly two items can have the same order.

MickL avatar Feb 27 '24 18:02 MickL

I second this.

adamleemiller avatar Mar 05 '24 08:03 adamleemiller

Right now the workaround is to keep a copy of the sorted array and sort it when sortable sorts its array. Then with newIndex I can find the element. This is how its done in the docs.

It wouldnt be required to do that when the event would simply return the element aswell.

MickL avatar Mar 05 '24 11:03 MickL