react-sortablejs
react-sortablejs copied to clipboard
[bug] swap plugin not swapping the items
The swap plugin does not seem to be working correctly. it does not swap the items and seems it just adds item to the next. (in gif)
Few important parts of code
import { ReactSortable, Sortable, Swap } from "react-sortablejs";
...
Sortable.mount(new Swap());
...
<ReactSortable swap swapThreshold={0.5} list={notes} setList={setNotes}>
{notes.map(i => noteCards(i))}
</ReactSortable>
Versions are
- react-sortable = 2.0.11
- react = 16.13.1
@waynevanson i think the change is required in the swap function in the main sortable library as it is directly consumed in react-sortable. i guess this is where the change is required.
I have this issue, too. Instead of placing the swap target where the source target was, it puts it one spot farther down the list.
This does not happen with SortableJS 1.10.2, only react-sortablejs.
Relatedly (?) animation does not work for me after enabling the swap plugin, but does work with vanilla SortableJS + Swap and with react-sortablejs without Swap.
@pg07codes Have You find The solution For This Bug?
@mtianyan no, i did not
@pg07codes the bug still here btw, the swap is not behave like what it should be.
Typescript types are missing as well.
Do you have any updates, I have a specific request to use the swap feature on the project. I have set the swap and it swaps the items to a one +1 index in the list.
I was testing the swap plugin and did some debugging and the update in the swap plugin changes the index in the dom correctly but then react rerenders it incorrectly one index down in the list.
This issue is probably a duplicate of #123 and #180.