@@ -32,10 +32,10 @@ type PressProps = {
32
32
bottom : number ,
33
33
left : number ,
34
34
} ,
35
+ preventDefault : boolean ,
35
36
} ;
36
37
37
38
type PressState = {
38
- defaultPrevented : boolean ,
39
39
isActivePressed : boolean ,
40
40
isActivePressStart : boolean ,
41
41
isAnchorTouched : boolean ,
@@ -206,14 +206,7 @@ function dispatchPressStartEvents(
206
206
state . isLongPressed = true ;
207
207
state . longPressTimeout = null ;
208
208
if ( props . onLongPress ) {
209
- const listener = e => {
210
- props . onLongPress ( e ) ;
211
- // TODO address this again at some point
212
- // if (e.nativeEvent.defaultPrevented) {
213
- // state.defaultPrevented = true;
214
- // }
215
- } ;
216
- dispatchEvent ( context , state , 'longpress' , listener ) ;
209
+ dispatchEvent ( context , state , 'longpress' , props . onLongPress ) ;
217
210
}
218
211
if ( props . onLongPressChange ) {
219
212
dispatchLongPressChangeEvent ( context , props , state ) ;
@@ -363,7 +356,6 @@ const PressResponder = {
363
356
targetEventTypes ,
364
357
createInitialState ( ) : PressState {
365
358
return {
366
- defaultPrevented : false ,
367
359
isActivePressed : false ,
368
360
isActivePressStart : false ,
369
361
isAnchorTouched : false ,
@@ -477,14 +469,7 @@ const PressResponder = {
477
469
props . onLongPressShouldCancelPress ( )
478
470
)
479
471
) {
480
- const listener = e => {
481
- props . onPress ( e ) ;
482
- // TODO address this again at some point
483
- // if (e.nativeEvent.defaultPrevented) {
484
- // state.defaultPrevented = true;
485
- // }
486
- } ;
487
- dispatchEvent ( context , state , 'press' , listener ) ;
472
+ dispatchEvent ( context , state , 'press' , props . onPress ) ;
488
473
}
489
474
}
490
475
}
@@ -607,9 +592,13 @@ const PressResponder = {
607
592
}
608
593
609
594
case 'click' : {
610
- if ( state . defaultPrevented ) {
611
- ( nativeEvent : any ) . preventDefault ( ) ;
612
- state . defaultPrevented = false ;
595
+ if ( isAnchorTagElement ( target ) ) {
596
+ const { ctrlKey , metaKey , shiftKey } = ( ( nativeEvent : any ) : MouseEvent ) ;
597
+ const preventDefault = props . preventDefault ;
598
+ // Check "open in new window/tab" key modifiers
599
+ if ( preventDefault !== false && ! shiftKey && ! ctrlKey && ! metaKey ) {
600
+ ( nativeEvent : any ) . preventDefault ( ) ;
601
+ }
613
602
}
614
603
}
615
604
}
0 commit comments