@@ -32,10 +32,10 @@ type PressProps = {
3232 bottom : number ,
3333 left : number ,
3434 } ,
35+ preventDefault : boolean ,
3536} ;
3637
3738type PressState = {
38- defaultPrevented : boolean ,
3939 isActivePressed : boolean ,
4040 isActivePressStart : boolean ,
4141 isAnchorTouched : boolean ,
@@ -206,14 +206,7 @@ function dispatchPressStartEvents(
206206 state . isLongPressed = true ;
207207 state . longPressTimeout = null ;
208208 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 ) ;
217210 }
218211 if ( props . onLongPressChange ) {
219212 dispatchLongPressChangeEvent ( context , props , state ) ;
@@ -363,7 +356,6 @@ const PressResponder = {
363356 targetEventTypes ,
364357 createInitialState ( ) : PressState {
365358 return {
366- defaultPrevented : false ,
367359 isActivePressed : false ,
368360 isActivePressStart : false ,
369361 isAnchorTouched : false ,
@@ -477,14 +469,7 @@ const PressResponder = {
477469 props . onLongPressShouldCancelPress ( )
478470 )
479471 ) {
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 ) ;
488473 }
489474 }
490475 }
@@ -607,9 +592,13 @@ const PressResponder = {
607592 }
608593
609594 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+ }
613602 }
614603 }
615604 }
0 commit comments