On-reorder $toIndex contains wrong value


#1

When using the $fromIndex and $toIndex arguments with the on-reorder callback, the values passed into the callback contain the wrong toIndex value. When dragging an item from the top down, the index values passed in are correct. However, when dragging an item from the bottom up, the toIndex value is one too large. You can see this by logging out the fromIndex and toIndex values in the controller. Example forked off your demo pen:


#2

I’m not seeing that.

I dragged Item 1 down 1 place below Item 2. From = 0, To = 1
Then, I dragged item 1 to the top above item 2. From = 1, To = 0

Next, I completely reloaded the sample.

I dragged Item 2 to the top above Item 1. From = 1, To = 0
I dragged Item 2 to below Item 1. From = 0, To = 1

Was it supposed to be different?


#3

You’re right. User error. I was not dragging far enough fr it to trigger the right index.