SortableJS / Sortable

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
https://sortablejs.github.io/Sortable/
MIT License
29.76k stars 3.7k forks source link

[bug] onEnd indexes are incorrect when using `draggable` #2379

Closed jamesst20 closed 6 months ago

jamesst20 commented 6 months ago

Versions

SortableJS 1.15.2

Reproduction

CodeSandbox

Why this is happening

It seems SortableJS internally doesn't care for the draggable class when it counts children so the <thead> count for one element always while not being draggable at all.

An ugly workaround is to offset by -1 in my function but this is most likely a bug.

jamesst20 commented 6 months ago

Workaround is to use the proper index:

        evt.oldDraggableIndex; // element's old index within old parent, only counting draggable elements
        evt.newDraggableIndex; // element's new index within new parent, only counting draggable elements