react-native/Libraries
Krzysztof Magiera bae9b2b206 Handle touchCancel properly in ScrollResponder
Summary:
Touch cancel events are currently being ignored by the ScrollView component. Currently scrollview responds both to scroll events and touchStart/touchMove/touchEnd events.

The reason why ScrollView listens to touchStart/touchEnd is so that it can update its `state.isTouching` param. This parameter then is used in `scrollResponderHandleScrollShouldSetResponder` to make the decision if scrollview should set the responder or not. So if `isTouching` is true (we've received touchStart) then ScrollView want to became a JS responder. This in turn is important for the case where we receive scroll events that does not necessarily need to trigger responder change, e.g. we don't want Scrollview to become JS responder if scroll events have been triggered by `scrollTo` in which case setting responder would put the whole responder system in a bogus state (note that responder can be released only by touchEnd or touchCancel, so if there is no touchEnd that follows scroll event then ScrollView will remain the responder and this would break next touch interaction).

It is therefore crucial for the ScrollView to reset `isTouching` state when touchCancel arrives, as otherwise the next scroll event would incorrectly trigger responder change.

On top of that ScrollView seems to be the only component in RN's core that registers to handle touchEnd but ignores touchCancel, which stands agains the comment added to `RCTRootView.cancelTouches` [here](https://github.com/facebook/react-native/commit/c14cc123d#diff-9cd70243bd2af75c613e29972bb1b41cR127).

This problem is difficult to test with a pure RN native app, as on Android it does not surface because of the `responderIgnoreScroll` flag that is being added to every scroll event, and it essentially makes the responder system ignore scroll events so they would never trigger responder change. On the other hand on iOS the cancel events are pretty rare. With pure RN app they can only be triggered by a "system" level interaction (e.g. when system alert dialog appears or when home button is clicked and there is a touch interaction happening). This issue becomes more prominent when RN app is embedded in a more sophisticated application that may use [`RCTRootView.cancelTouches`](1e8f3b1102/React/Base/RCTRootView.h (L130)) method to block RNs gesture recognizers in some cases or with third-party libraries that deals with touch events like [react-native-gesture-handler](https://github.com/kmagiera/react-native-gesture-handler) that also calls into the method when native touch interaction is detected.
Closes https://github.com/facebook/react-native/pull/16004

Differential Revision: D6003063

Pulled By: shergin

fbshipit-source-id: f6495ffc57a5f996117b5bd80478bb1a58d2d799
2017-10-19 15:30:44 -07:00
..
ART Fix format warnings for clang 5.0 2017-09-25 10:30:53 -07:00
ActionSheetIOS Add minimal example to actionsheet 2017-10-10 03:32:08 -07:00
Alert support null titles in AlertIOS 2017-09-11 16:08:03 -07:00
Animated Update Animated docs to mention potential issues with VirtualizedList 2017-10-13 17:50:17 -07:00
AppState Avoid race condition for AppState.currentState 2017-08-18 13:14:59 -07:00
BatchedBridge Improve flow typing and linting for MessageQueue 2017-10-10 16:32:28 -07:00
Blob @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
BugReporting Patch up for future React Sync 2017-02-08 14:50:43 -08:00
CameraRoll Fix crash when trying to load photo library assets with nil image url 2017-09-14 12:02:27 -07:00
Components Handle touchCancel properly in ScrollResponder 2017-10-19 15:30:44 -07:00
Core Fix test suite when running on a feature branch 2017-10-19 13:53:27 -07:00
EventEmitter RN: Improve NativeEventEmitter Flow Types 2017-10-13 08:04:17 -07:00
Experimental Add SwipeableFlatList 2017-09-28 22:16:08 -07:00
Geolocation @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
Image Android: put all non-drawable resources to `res/raw` 2017-10-11 15:11:29 -07:00
Inspector @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
Interaction Improve flow typing and linting for MessageQueue 2017-10-10 16:32:28 -07:00
JSInspector Add Network agent 2016-11-02 12:29:15 -07:00
LayoutAnimation @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
Linking fix flow warning and typo 2017-09-08 14:46:14 -07:00
LinkingIOS Standardize project indentation settings on 2 spaces 2017-07-31 05:20:03 -07:00
Lists VirtualizedList: fix bug where onViewableItemsChanged wouldn't trigger 2017-10-16 04:35:05 -07:00
Modal Add onDismiss to Modal.js 2017-09-21 15:01:52 -07:00
NativeAnimation Bunch of utility funcs were moved to RCTUIManagerUtils 2017-09-26 14:08:28 -07:00
Network Update the `NetInfo.isConnected` example code so that it uses the new `connectionChange` event 2017-10-13 18:02:06 -07:00
Performance Gate more code with if (__DEV__) { } 2017-08-14 07:19:00 -07:00
PermissionsAndroid Update documentation for PermissionsAndroid 2017-08-16 15:01:51 -07:00
PushNotificationIOS Fix flowtype errors for PushNotificationIOS 2017-08-14 12:03:18 -07:00
RCTTest Improve DX for FBReactKitIntegrationTests 2017-09-21 18:30:38 -07:00
ReactNative Implement gating support for direction-aware API changes 2017-10-18 19:33:31 -07:00
Renderer React sync for revisions b5ac963...5f93ee6f6 2017-10-04 10:16:15 -07:00
Sample Standardize project indentation settings on 2 spaces 2017-07-31 05:20:03 -07:00
Settings Fix infinite recursion in RCTSettingsManager init 2017-08-09 09:39:40 -07:00
Share Fix error in flow types 2017-09-12 05:50:26 -07:00
Storage correctly order ASyncStorage 2017-02-21 15:18:40 -08:00
StyleSheet iOS: Implement margin(Start|End) styles for RN 2017-10-18 19:33:31 -07:00
Text Fix typo in Text 2017-10-10 13:20:18 -07:00
Utilities Run eslint --fix 2017-10-09 17:46:44 -07:00
Vibration Run eslint --fix 2017-10-09 17:46:44 -07:00
WebSocket remove RCTWebSocketObserver 2017-10-04 19:17:07 -07:00
Wrapper Opensourcing RCTWrapper 2017-10-09 17:22:35 -07:00
fishhook Merge fishhook.xcodeproj in RCTWebSocket 2017-08-09 07:48:09 -07:00
polyfills Use proper script way to clone Emoji files from www 2017-08-21 16:29:39 -07:00
react-native Add SwipeableFlatList 2017-09-28 22:16:08 -07:00
vendor @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
.eslintrc Disallow trailing commas in react-native-github 2017-08-17 16:20:04 -07:00
Promise.js @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00
promiseRejectionIsError.js @allow-large-files Flow v0.54.0 2017-09-06 03:33:43 -07:00