File tree 2 files changed +46
-0
lines changed
packages/react-interactions/events/src/dom
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';
12
12
import React from 'react' ;
13
13
import { useTap } from 'react-interactions/events/tap' ;
14
14
import { useKeyboard } from 'react-interactions/events/keyboard' ;
15
+ import warning from 'shared/warning' ;
15
16
16
17
const emptyObject = { } ;
17
18
@@ -48,6 +49,8 @@ type PressEvent = {|
48
49
type : PressEventType ,
49
50
x : number ,
50
51
y : number ,
52
+ preventDefault : ( ) => void ,
53
+ stopPropagation : ( ) => void ,
51
54
| } ;
52
55
53
56
function createGestureState ( e : any , type : PressEventType ) : PressEvent {
@@ -67,6 +70,26 @@ function createGestureState(e: any, type: PressEventType): PressEvent {
67
70
type,
68
71
x : e . x ,
69
72
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
+ } ,
70
93
} ;
71
94
}
72
95
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import type {
19
19
20
20
import React from 'react' ;
21
21
import { DiscreteEvent , UserBlockingEvent } from 'shared/ReactTypes' ;
22
+ import warning from 'shared/warning' ;
22
23
23
24
type PressProps = { |
24
25
disabled : boolean ,
@@ -93,6 +94,8 @@ type PressEvent = {|
93
94
type : PressEventType ,
94
95
x : null | number ,
95
96
y : null | number ,
97
+ preventDefault : ( ) => void ,
98
+ stopPropagation : ( ) => void ,
96
99
| } ;
97
100
98
101
const hasPointerEvents =
@@ -185,6 +188,26 @@ function createPressEvent(
185
188
type,
186
189
x : clientX ,
187
190
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
+ } ,
188
211
} ;
189
212
}
190
213
You can’t perform that action at this time.
0 commit comments