thisbeyond / solid-dnd

A lightweight, performant, extensible drag and drop toolkit for Solid JS.
https://solid-dnd.com
MIT License
505 stars 35 forks source link

<SortableProvider> doesn't work when it contains <Index> instead of <For> #69

Closed jyasskin closed 1 year ago

jyasskin commented 1 year ago

If you take the sortable-vertical-list example and replace the <For> with <Index>, getting https://stackblitz.com/edit/vitejs-vite-9tioae?file=src/App.tsx, dragging stops moving the right elements. For example, if you drag the "1" to the second position, you get "2, 1, 3" as expected, but if you then drag the 1 from there to the third position, the overlay shows "2" during the drag, and the final order is "1, 3, 2" instead of the expected "2, 3, 1".

martinpengellyphillips commented 1 year ago

I wouldn't expect it to work with Index as the current algorithm requires referential key change, whereas index uses the array index which is effectively unchanging when reordering.