Open KhalilKhalaf opened 7 years ago
Have not really tested with TouchableOpacity, but in my case I used with touchable native component and it worked fine:
(speaker icons inside rows are native and touchable).
Could you fork and modify Row component in Basic example to reproduce your case?
I see, can you please share the code of your touchable? Just for documentation and for me to follow your pattern if that is possible.
Beautiful work man and good job 👍
I see, can you please share the code of your touchable?
No, I can't, it is private.
What do you mean by touchable native? I tried TouchableHighlight and standard Button and both did not work on mobile (but worked on simulator)
What do you mean by touchable native?
native component, that can be touched
I've created pull request for this issue: https://github.com/gitim/react-native-sortable-list/pull/64
First off I'd like to stay this library is great, has been so helpful!
I just wanted to chime in because I'm currently experiencing the same issues. I have TouchableOpacity
elements in my row. The TouchableOpacity
when tapped, do the whole opacity fade so they are receiving the touch but the onPress never gets fired. I'm assuming maybe the touch event is bubbling up to the PanResponder of SortableList
component?
Could be related to this issue? https://github.com/facebook/react-native/issues/3082
This bug because of setting onMoveShouldSetPanResponder
in Row, but it is required for enabling dragging by any point of the row, this commit fixes the initial bug, but disables dragging by holding row by touchable elements. So, I am still investigating how to fix the bug w/o adding new.
upd: the issue is described in stackoverflow
Same issue for me. I'm trying to replicate iOS's editable list behavior, where you can drag to re-arrange, or tap the red circle to delete:
Unfortunately, this only works on the Simulator. On both iOS and Android physical devices, you can't reliably tap the red circle. Every once in a blue moon the touch will respond, but it's rare.
Any updates on how to get around this? Maybe if there were Hitbox support this issue would be mitigated.
I figured out the problem and came up with a partial workaround. The problem is that when you use onPress
, react-native-sortable-list
"steals" the touch event away from your custom touchable. This happens after 200ms (the default activation time). So what you need to do is "beat" react-native-sortable-list
to the punch. You can do this by using onPressIn
instead of onPress
- all RN touchables support this prop.
onPressIn
is called immediately, so it will be invoked before react-native-sortable-list
's invocation that takes place at 200ms, so the touch is never "stolen away".
The only caveat here is that the touch happens on press down, rather than the usual on press up, so the user can't cancel their touch event by sliding their finger away. But for my situation, it's good enough until this issue is fixed in this library.
I've had the same issue and the best way to avoid it is using onPressRow prop instead of the inner component onPress. You can get the item index from the function param.
onPressRow? (function) (key) => void Called when a row was pressed.
So on my simulator, I can press on a row to navigate to a screen, and I can long press a row to drag then drop it.
But on the iphone, row onPress does not work. Is it only me?
and then MyComponent renders this: (I use onPress in the one and only
TouchableOpacity
)