mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-28 12:24:51 +08:00
[fix] PanResponder grant firing twice on touch devices
Touch events can produce trailing mouse events, which cause unwanted events to fire in the responder event system. This issue is avoided in `Touchable` by cancelling the event in the responder release callback. To fix the issue in other areas, like the PaneResponder, this hack is moved into `createElement` and applied to event `onResponderRelease` callback. Fix #802
This commit is contained in:
@@ -424,13 +424,6 @@ const TouchableMixin = {
|
||||
*/
|
||||
touchableHandleResponderRelease: function(e: Event) {
|
||||
this._receiveSignal(Signals.RESPONDER_RELEASE, e);
|
||||
// Browsers fire mouse events after touch events. This causes the
|
||||
// 'onResponderRelease' handler to be called twice for Touchables.
|
||||
// Auto-fix this issue by calling 'preventDefault' to cancel the mouse
|
||||
// events.
|
||||
if (e.cancelable && !e.isDefaultPrevented()) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,6 +52,17 @@ const adjustProps = domProps => {
|
||||
if (isEventHandler) {
|
||||
if (isButtonRole && isDisabled) {
|
||||
domProps[propName] = undefined;
|
||||
} else if (propName === 'onResponderRelease') {
|
||||
// Browsers fire mouse events after touch events. This causes the
|
||||
// 'onResponderRelease' handler to be called twice for Touchables.
|
||||
// Auto-fix this issue by calling 'preventDefault' to cancel the mouse
|
||||
// events.
|
||||
domProps[propName] = e => {
|
||||
if (e.cancelable && !e.isDefaultPrevented()) {
|
||||
e.preventDefault();
|
||||
}
|
||||
return prop(e);
|
||||
};
|
||||
} else {
|
||||
// TODO: move this out of the render path
|
||||
domProps[propName] = e => {
|
||||
|
||||
Reference in New Issue
Block a user