File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
packages/react-interactions/events/src/dom Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import type {PointerType} from 'shared/ReactDOMTypes';
1212import React from 'react' ;
1313import { useTap } from 'react-interactions/events/tap' ;
1414import { useKeyboard } from 'react-interactions/events/keyboard' ;
15+ import warning from 'shared/warning' ;
1516
1617const emptyObject = { } ;
1718
@@ -48,6 +49,8 @@ type PressEvent = {|
4849 type : PressEventType ,
4950 x : number ,
5051 y : number ,
52+ preventDefault : ( ) => void ,
53+ stopPropagation : ( ) => void ,
5154| } ;
5255
5356function createGestureState ( e : any , type : PressEventType ) : PressEvent {
@@ -67,6 +70,26 @@ function createGestureState(e: any, type: PressEventType): PressEvent {
6770 type,
6871 x : e . x ,
6972 y : e . y ,
73+ preventDefault ( ) {
74+ // NO-OP, we should remove this in the future
75+ if ( __DEV__ ) {
76+ warning (
77+ false ,
78+ 'preventDefault is not available on event objects created from event responder modules (React Flare). ' +
79+ 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.preventDefault() }`' ,
80+ ) ;
81+ }
82+ } ,
83+ stopPropagation ( ) {
84+ // NO-OP, we should remove this in the future
85+ if ( __DEV__ ) {
86+ warning (
87+ false ,
88+ 'stopPropagation is not available on event objects created from event responder modules (React Flare). ' +
89+ 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.stopPropagation() }`' ,
90+ ) ;
91+ }
92+ } ,
7093 } ;
7194}
7295
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import type {
1919
2020import React from 'react' ;
2121import { DiscreteEvent , UserBlockingEvent } from 'shared/ReactTypes' ;
22+ import warning from 'shared/warning' ;
2223
2324type PressProps = { |
2425 disabled : boolean ,
@@ -93,6 +94,8 @@ type PressEvent = {|
9394 type : PressEventType ,
9495 x : null | number ,
9596 y : null | number ,
97+ preventDefault : ( ) => void ,
98+ stopPropagation : ( ) => void ,
9699| } ;
97100
98101const hasPointerEvents =
@@ -185,6 +188,26 @@ function createPressEvent(
185188 type,
186189 x : clientX ,
187190 y : clientY ,
191+ preventDefault ( ) {
192+ // NO-OP, we should remove this in the future
193+ if ( __DEV__ ) {
194+ warning (
195+ false ,
196+ 'preventDefault is not available on event objects created from event responder modules (React Flare). ' +
197+ 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.preventDefault() }`' ,
198+ ) ;
199+ }
200+ } ,
201+ stopPropagation ( ) {
202+ // NO-OP, we should remove this in the future
203+ if ( __DEV__ ) {
204+ warning (
205+ false ,
206+ 'stopPropagation is not available on event objects created from event responder modules (React Flare). ' +
207+ 'Try wrapping in a conditional, i.e. `if (event.type !== "press") { event.stopPropagation() }`' ,
208+ ) ;
209+ }
210+ } ,
188211 } ;
189212}
190213
You can’t perform that action at this time.
0 commit comments