From 17f8a674b832e25e973962f77205d13bd3f2e878 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Tue, 13 Feb 2018 13:34:49 -0800 Subject: [PATCH] [fix] ResponderEventPlugin skips 'mouseup' when no touch is active Prevent the responder system recording 'mouseup' events if there is no active 'touch'. Fix #816 --- .../src/modules/injectResponderEventPlugin/index.js | 4 ++-- .../storybook/2-apis/PanResponder/examples/DraggableCircle.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-native-web/src/modules/injectResponderEventPlugin/index.js b/packages/react-native-web/src/modules/injectResponderEventPlugin/index.js index 107bb2f4..59283625 100644 --- a/packages/react-native-web/src/modules/injectResponderEventPlugin/index.js +++ b/packages/react-native-web/src/modules/injectResponderEventPlugin/index.js @@ -43,8 +43,8 @@ const originalExtractEvents = ResponderEventPlugin.extractEvents; ResponderEventPlugin.extractEvents = (topLevelType, targetInst, nativeEvent, nativeEventTarget) => { const hasActiveTouches = ResponderTouchHistoryStore.touchHistory.numberActiveTouches > 0; if ( - // Filter out mousemove events when there hasn't been a touch yet - (topLevelType === topMouseMove && !hasActiveTouches) || + // Filter out mousemove and mouseup events when a touch hasn't started yet + ((topLevelType === topMouseMove || topLevelType === topMouseUp) && !hasActiveTouches) || // Filter out events from wheel/middle and right click. (nativeEvent.button === 1 || nativeEvent.button === 2) ) { diff --git a/website/storybook/2-apis/PanResponder/examples/DraggableCircle.js b/website/storybook/2-apis/PanResponder/examples/DraggableCircle.js index c262ba1d..89e12a41 100644 --- a/website/storybook/2-apis/PanResponder/examples/DraggableCircle.js +++ b/website/storybook/2-apis/PanResponder/examples/DraggableCircle.js @@ -71,7 +71,7 @@ export default class DraggableCircle extends PureComponent { _handleMoveShouldSetPanResponder = (e: Object, gestureState: Object): boolean => { // Should we become active when the user moves a touch over the circle? - return false; + return true; }; _handlePanResponderGrant = (e: Object, gestureState: Object) => {