react-native-swipe-list-view
react-native-swipe-list-view copied to clipboard
[IOS] Wrong vertical scroll offset when stressing a horizontal nested component
Hi,
Describe the bug When using a simple case (vertical list with items having two actions on the right) it is possible to stuck the vertical scroll in a normally "impossible" state. For example, I can stuck it at an offset of -3, which should never happens with a normal Scrollable item. It is occurring on iOS (I did not test on Android) on all modern devices I tested (iPhone 8+, XR, 11 Pro).
To Reproduce I created 3xpedia/swipe-list-view-reproduction-repo in order to easily reproduce.
Screenshots

Environment (please complete the following information):
- OS: iOS (tested on all 14.x.x versions)
- RNSLV Version: 3.2.7, also saw it in latest 2.x.x version
- RN Version: 0.64.1 also observed in 0.63.x
notes
- It is reproducible on emulator and physical device.
- The bug can also be reproduced in a strange way : keep the app active on a screen with this component, wait enough for the phone to lock itself (reducing the lock time to 30s can help), when unlocking the phone the SwipeListView is sometime stuck with a negative offset. It is really hard to reproduce this way (sometime it takes up to an hour of trial to manage reproducing it) but this is the most problematic case.
Hi, I'm sorry to bully you with this, I understand it's quite complicated to reproduce but it's quite important to have it fixed on my side. I can take some time this week-end to work on it but I would really appreciate if you had some idea to give me (where to search, early ideas what could be the cause, ...). It would save me some time, you know this code better than me :) Many thanks
Hey @3xpedia thank you for the example repo, that is very helpful. I will try to look into this over the weekend. In the meantime I would start here:
https://github.com/jemise111/react-native-swipe-list-view/blob/master/components/SwipeRow.js#L304
It's possible that the list is being scrolled a bit past 0, then the scroll is being locked by the SwipeRow, and then when the scroll is unlocked the scrollview doesn't know it needs to bounce back to 0. Just a theory..
Hey @3xpedia I've looked into this some more and I'm sorry to say I'm not sure what an ideal solution would be. I can reproduce it pretty consistently now by swiping and scrolling at the same time. The issue is when it is detected that a swipe has begun the vertical scrolling is locked. If there happens to be an offset when it's locked the offset will persist even after the swipe. Let's take the case of a negative offset:
Under normal circumstances it looks like this:
- User drags scrollview down
- User releases finger from screen
- scrollview snaps back to offset 0
However with swiping and scrolling this looks like:
- User quickly scrolls and swipes
- The swipe locks scrolling at the current offset (negative number)
- The swipe is ended, user releases finger from screen
- Scroll is re-enabled, but the scrollview doesn't know to return to the previous offset
(4) is the problem. You could do some manual work to track the scroll offset at the beginning and end of a swipe and if there is a mismatch then manually scroll the scrollview to the previous offset, but TBH it sounds like more trouble then what it's worth.
Open to suggestions if you have any, thanks