@@ -426,7 +426,8 @@ const PressResponder = {
426426 props : PressProps ,
427427 state : PressState ,
428428 ) : void {
429- const { target , type , nativeEvent } = event ;
429+ const { target , type } = event ;
430+ const nativeEvent : any = event . nativeEvent ;
430431
431432 switch ( type ) {
432433 /**
@@ -442,21 +443,23 @@ const PressResponder = {
442443 const pointerType = getPointerType ( nativeEvent ) ;
443444 state . pointerType = pointerType ;
444445
445- if ( pointerType === 'mouse' || type === 'mousedown' ) {
446- if (
447- // Ignore right- and middle-clicks
448- nativeEvent . button === 1 ||
449- nativeEvent . button === 2 ||
450- // Ignore pressing on hit slop area with mouse
451- context . isPositionWithinTouchHitTarget (
452- target . ownerDocument ,
453- ( nativeEvent : any ) . x ,
454- ( nativeEvent : any ) . y ,
455- )
456- ) {
457- return ;
458- }
446+ // Ignore any device buttons except left-mouse and touch/pen contact
447+ if ( nativeEvent . button > 0 ) {
448+ return ;
459449 }
450+
451+ // Ignore pressing on hit slop area with mouse
452+ if (
453+ ( pointerType === 'mouse' || type === 'mousedown' ) &&
454+ context . isPositionWithinTouchHitTarget (
455+ target . ownerDocument ,
456+ nativeEvent . x ,
457+ nativeEvent . y ,
458+ )
459+ ) {
460+ return ;
461+ }
462+
460463 state . pressTarget = target ;
461464 state . isPressWithinResponderRegion = true ;
462465 dispatchPressStartEvents ( context , props , state ) ;
@@ -574,7 +577,7 @@ const PressResponder = {
574577
575578 if ( type !== 'touchcancel' && props . onPress ) {
576579 // Find if the X/Y of the end touch is still that of the original target
577- const changedTouch = ( nativeEvent : any ) . changedTouches [ 0 ] ;
580+ const changedTouch = nativeEvent . changedTouches [ 0 ] ;
578581 const doc = ( target : any ) . ownerDocument ;
579582 const fromTarget = doc . elementFromPoint (
580583 changedTouch . screenX ,
@@ -609,12 +612,12 @@ const PressResponder = {
609612 case 'keypress ': {
610613 if (
611614 ! context . hasOwnership ( ) &&
612- isValidKeyPress ( ( nativeEvent : any ) . key )
615+ isValidKeyPress ( nativeEvent . key )
613616 ) {
614617 if ( state . isPressed ) {
615618 // Prevent spacebar press from scrolling the window
616- if ( ( nativeEvent : any ) . key === ' ' ) {
617- ( nativeEvent : any ) . preventDefault ( ) ;
619+ if ( nativeEvent . key === ' ' ) {
620+ nativeEvent . preventDefault ( ) ;
618621 }
619622 } else {
620623 const pointerType = getPointerType ( nativeEvent ) ;
@@ -627,7 +630,7 @@ const PressResponder = {
627630 break ;
628631 }
629632 case 'keyup' : {
630- if ( state . isPressed && isValidKeyPress ( ( nativeEvent : any ) . key ) ) {
633+ if ( state . isPressed && isValidKeyPress ( nativeEvent . key ) ) {
631634 const wasLongPressed = state . isLongPressed ;
632635 dispatchPressEndEvents ( context , props , state ) ;
633636 if ( state . pressTarget !== null && props . onPress ) {
@@ -659,11 +662,11 @@ const PressResponder = {
659662
660663 case 'click' : {
661664 if ( isAnchorTagElement ( target ) ) {
662- const { ctrlKey , metaKey , shiftKey } = ( ( nativeEvent : any ) : MouseEvent ) ;
665+ const { ctrlKey , metaKey , shiftKey } = ( nativeEvent : MouseEvent ) ;
663666 // Check "open in new window/tab" and "open context menu" key modifiers
664667 const preventDefault = props . preventDefault ;
665668 if ( preventDefault !== false && ! shiftKey && ! metaKey && ! ctrlKey ) {
666- ( nativeEvent : any ) . preventDefault ( ) ;
669+ nativeEvent . preventDefault ( ) ;
667670 }
668671 }
669672 break ;
@@ -672,7 +675,7 @@ const PressResponder = {
672675 case 'contextmenu ': {
673676 if ( state . isPressed ) {
674677 if ( props . preventDefault !== false ) {
675- ( nativeEvent : any ) . preventDefault ( ) ;
678+ nativeEvent . preventDefault ( ) ;
676679 } else {
677680 state . shouldSkipMouseAfterTouch = false ;
678681 dispatchPressEndEvents ( context , props , state ) ;
0 commit comments