computerjazz / react-native-draggable-flatlist

A drag-and-drop-enabled FlatList for React Native
MIT License
1.95k stars 409 forks source link

Intermittently cannot drag top or bottom item #441

Open ericdolson opened 1 year ago

ericdolson commented 1 year ago

There are times where the first and/or last item can enter the draggable state but the entire list moves and dragging is not possible. See video:

https://user-images.githubusercontent.com/2644529/210892257-0a2f2d83-8ef1-4391-869e-2becb6497e80.MP4

I could not get the bottom one to stick for this recording but it has happened several times while exploring using this library (which is AMAZING btw!).

Once an item enters the isDragging state (zoomed) and the whole list scrolls, after I remove my finger the item remains in the isDragging state (zoomed). I have to touch the screen or interact with some other item before the item will stop appearing to be in the isDragging state.

Platform & Dependencies Please list any applicable dependencies in addition to those below (react-navigation etc).

ericdolson commented 1 year ago

Interestingly I think I found the problem at a high level. When my item's key is a zero, it turns out that this list-dragging behavior happens no matter where the item is in the list. So if I drag all items above the 0 item which paces it at the bottom, then that is how I saw the bottom sticks. If there 0 is in the middle (anywhere) it happens there too.

The fix was to make my key non-zero. I wonder if there is a falsey check somewhere causing this bug?

ericdolson commented 1 year ago

Yup, must be a falsey check in the code. I converted my keys to strings but left one key as an empty string, falsey, and that item while trying to drag reveals the bug.

This isn't a big deal because I do not expect to use falsey keys, but hopefully it is an easy fix for later so as to not trip others up.

Thanks for a wonderful library and for your hard work!