MaxLeiter / sortablejs-vue3

A thin wrapper around Sortable.js for Vue 3
https://sortablejs-vue3.maxleiter.com
MIT License
378 stars 19 forks source link

Events should also return the element #105

Open MickL opened 7 months ago

MickL commented 7 months ago

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.

adamleemiller commented 7 months ago

I second this.

MickL commented 7 months ago

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.