computerjazz / react-native-draggable-flatlist

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

Scrolling doesn't seem to work in web #494

Open sakisev opened 1 year ago

sakisev commented 1 year ago

I am using this library to create a sortable list that works on both mobile and web, while on mobile it works just fine the web version doesn't seem to scroll the screen while dragging an element from the list.

To Reproduce This is reproducible on the snack link provided in the README.md file using the basic example https://snack.expo.dev/@computerjazz/draggable-flatlist-examples?platform=web

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

juhasuni commented 11 months ago

The issue is on this line: https://github.com/computerjazz/react-native-draggable-flatlist/blob/ebfddc4877e8f65d5391a748db61b9cd030430ba/src/components/DraggableFlatList.tsx#L383

It disables scrolling for the underlying ScrollView when you start dragging an item. In the web this basically disables the overflow completely which means that when the node is asked to scroll, it does nothing. Apparently on other platforms this doesn't truly disable the scrolling for the element, but simply disables any gesture based scrolling (in other words any scrolling directly initiated by the user).

This patch fixes it for the Web:

scrollEnabled: (!activeKey || Platform.OS === 'web') && scrollEnabled,

I've got no idea if this change has other consequences.

One might also say that the issue is actually react-native-web's issue as scrollEnabled behavior is not consistent with other platforms. However, I'm afraid it cannot be consistent in this case or at least it would be challenging to make it consistent.