36
Views
2
Comments
[SortableJS] NewIndex and OldIndex not giving the correct values in higher ranges of a list.
sortablejs
Reactive icon
Forge asset by João Lopes
Application Type
Reactive

My team uses this component and it works great for small lists. We use the values given by the NewIndex to set as an order variable for that item on the list and update that list item accordingly. Then sort the list by the order number. When trying to do this for larger lists the NewIndex JSON value and the OldIndex JSON value are not correct and can be off by quite a bit. This then means that the wrong value is being assigned to the list item and after sorting the item does not appear where it should be. 


I have attached an OML. In the SortableJSListOnDragEnd client action debug on the assign. You will see that the index numbers are correct for small movements in the list. But if you try and drag the top of the list to the bottom the index values are off. 

SBSandbox.oml
2021-01-21 14-05-49
José Pedro Proença
 
MVP

Hi Spencer Buhler, thanks for sharing this issue!

I just looked a bit into it and it seems that the table is not rendered entirely in the beginning, but only the first 120 items.
Since the sortable object is created in the OnReady event, probably only the first 120 items will be considered by the sortable.js library.


I'll try to find a workaround for this in the https://sortablejs.github.io/Sortable/ and on https://github.com/SortableJS/react-sortablejs. For now the on only solution would be to have smaller lists with pagination, which might not work in your case.

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi @Spencer Buhler,

I'm thinking this is caused by list virtualization, so a workaround could be to disable that for this list.

I had a try with your demo oml, and can drag from 1 to 200+ without error

Dorine

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.