[fix] ResponderEventPlugin skips 'mouseup' when no touch is active

Prevent the responder system recording 'mouseup' events if there is no
active 'touch'.

Fix #816
This commit is contained in:
Nicolas Gallagher
2018-02-13 13:34:49 -08:00
parent b8080ba775
commit 17f8a674b8
2 changed files with 3 additions and 3 deletions
@@ -43,8 +43,8 @@ const originalExtractEvents = ResponderEventPlugin.extractEvents;
ResponderEventPlugin.extractEvents = (topLevelType, targetInst, nativeEvent, nativeEventTarget) => { ResponderEventPlugin.extractEvents = (topLevelType, targetInst, nativeEvent, nativeEventTarget) => {
const hasActiveTouches = ResponderTouchHistoryStore.touchHistory.numberActiveTouches > 0; const hasActiveTouches = ResponderTouchHistoryStore.touchHistory.numberActiveTouches > 0;
if ( if (
// Filter out mousemove events when there hasn't been a touch yet // Filter out mousemove and mouseup events when a touch hasn't started yet
(topLevelType === topMouseMove && !hasActiveTouches) || ((topLevelType === topMouseMove || topLevelType === topMouseUp) && !hasActiveTouches) ||
// Filter out events from wheel/middle and right click. // Filter out events from wheel/middle and right click.
(nativeEvent.button === 1 || nativeEvent.button === 2) (nativeEvent.button === 1 || nativeEvent.button === 2)
) { ) {
@@ -71,7 +71,7 @@ export default class DraggableCircle extends PureComponent {
_handleMoveShouldSetPanResponder = (e: Object, gestureState: Object): boolean => { _handleMoveShouldSetPanResponder = (e: Object, gestureState: Object): boolean => {
// Should we become active when the user moves a touch over the circle? // Should we become active when the user moves a touch over the circle?
return false; return true;
}; };
_handlePanResponderGrant = (e: Object, gestureState: Object) => { _handlePanResponderGrant = (e: Object, gestureState: Object) => {