mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[react-interactions] Add no-op stopPropagation + preventDefault to Press (#16868)
Fix
This commit is contained in:
@@ -12,6 +12,7 @@ import type {PointerType} from 'shared/ReactDOMTypes';
|
||||
import React from 'react';
|
||||
import {useTap} from 'react-interactions/events/tap';
|
||||
import {useKeyboard} from 'react-interactions/events/keyboard';
|
||||
import warning from 'shared/warning';
|
||||
|
||||
const emptyObject = {};
|
||||
|
||||
@@ -48,6 +49,8 @@ type PressEvent = {|
|
||||
type: PressEventType,
|
||||
x: number,
|
||||
y: number,
|
||||
preventDefault: () => void,
|
||||
stopPropagation: () => void,
|
||||
|};
|
||||
|
||||
function createGestureState(e: any, type: PressEventType): PressEvent {
|
||||
@@ -67,6 +70,26 @@ function createGestureState(e: any, type: PressEventType): PressEvent {
|
||||
type,
|
||||
x: e.x,
|
||||
y: e.y,
|
||||
preventDefault() {
|
||||
// NO-OP, we should remove this in the future
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
false,
|
||||
'preventDefault is not available on event objects created from event responder modules (React Flare). ' +
|
||||
'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.preventDefault() }`',
|
||||
);
|
||||
}
|
||||
},
|
||||
stopPropagation() {
|
||||
// NO-OP, we should remove this in the future
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
false,
|
||||
'stopPropagation is not available on event objects created from event responder modules (React Flare). ' +
|
||||
'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.stopPropagation() }`',
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import type {
|
||||
|
||||
import React from 'react';
|
||||
import {DiscreteEvent, UserBlockingEvent} from 'shared/ReactTypes';
|
||||
import warning from 'shared/warning';
|
||||
|
||||
type PressProps = {|
|
||||
disabled: boolean,
|
||||
@@ -93,6 +94,8 @@ type PressEvent = {|
|
||||
type: PressEventType,
|
||||
x: null | number,
|
||||
y: null | number,
|
||||
preventDefault: () => void,
|
||||
stopPropagation: () => void,
|
||||
|};
|
||||
|
||||
const hasPointerEvents =
|
||||
@@ -185,6 +188,26 @@ function createPressEvent(
|
||||
type,
|
||||
x: clientX,
|
||||
y: clientY,
|
||||
preventDefault() {
|
||||
// NO-OP, we should remove this in the future
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
false,
|
||||
'preventDefault is not available on event objects created from event responder modules (React Flare). ' +
|
||||
'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.preventDefault() }`',
|
||||
);
|
||||
}
|
||||
},
|
||||
stopPropagation() {
|
||||
// NO-OP, we should remove this in the future
|
||||
if (__DEV__) {
|
||||
warning(
|
||||
false,
|
||||
'stopPropagation is not available on event objects created from event responder modules (React Flare). ' +
|
||||
'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.stopPropagation() }`',
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user