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

[bug] swap plugin not swapping the items

Open pg07codes opened this issue 4 years ago • 8 comments

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)

Peek 2020-05-11 11-57

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

pg07codes avatar May 11 '20 06:05 pg07codes

@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.

pg07codes avatar May 12 '20 06:05 pg07codes

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.

maxbarry avatar May 15 '20 07:05 maxbarry

@pg07codes Have You find The solution For This Bug?

mtianyan avatar Aug 06 '20 09:08 mtianyan

@mtianyan no, i did not

pg07codes avatar Aug 06 '20 13:08 pg07codes

@pg07codes the bug still here btw, the swap is not behave like what it should be.

VnVentX avatar Jan 25 '21 15:01 VnVentX

Typescript types are missing as well.

marcelmokos avatar Feb 09 '21 12:02 marcelmokos

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.

marcelmokos avatar Feb 22 '21 11:02 marcelmokos

This issue is probably a duplicate of #123 and #180.

maxbarry avatar Feb 22 '21 21:02 maxbarry