@@ -350,23 +350,26 @@ function isActivePointer(
350350 }
351351}
352352
353- function isAuxiliary ( buttons : number , nativeEvent : any ) : boolean {
353+ function isAuxiliary ( buttons : number , event : ReactDOMResponderEvent ) : boolean {
354+ const nativeEvent : any = event . nativeEvent ;
355+ const isPrimaryPointer =
356+ buttons === buttonsEnum . primary || event . pointerType === 'touch' ;
354357 return (
355358 // middle-click
356359 buttons === buttonsEnum . auxiliary ||
357360 // open-in-new-tab
358- ( buttons === buttonsEnum . primary && nativeEvent . metaKey ) ||
361+ ( isPrimaryPointer && nativeEvent . metaKey ) ||
359362 // open-in-new-window
360- ( buttons === buttonsEnum . primary && nativeEvent . shiftKey )
363+ ( isPrimaryPointer && nativeEvent . shiftKey )
361364 ) ;
362365}
363366
364367function shouldActivate ( event : ReactDOMResponderEvent ) : boolean {
365368 const nativeEvent : any = event . nativeEvent ;
366- const pointerType = event . pointerType ;
367- const buttons = nativeEvent . buttons ;
368- const isValidButton = buttons === buttonsEnum . primary ;
369- return pointerType === 'touch' || ( isValidButton && ! hasModifierKey ( event ) ) ;
369+ const isPrimaryPointer =
370+ nativeEvent . buttons === buttonsEnum . primary ||
371+ event . pointerType === 'touch' ;
372+ return isPrimaryPointer && ! hasModifierKey ( event ) ;
370373}
371374
372375/**
@@ -514,10 +517,7 @@ const responderImpl = {
514517
515518 if ( ! state . isActive ) {
516519 const activate = shouldActivate ( event ) ;
517- const activateAuxiliary = isAuxiliary (
518- nativeEvent . buttons ,
519- nativeEvent ,
520- ) ;
520+ const activateAuxiliary = isAuxiliary ( nativeEvent . buttons , event ) ;
521521
522522 if ( activate || activateAuxiliary ) {
523523 state . buttons = nativeEvent . buttons ;
@@ -531,7 +531,9 @@ const responderImpl = {
531531 }
532532 }
533533
534- if ( activate ) {
534+ if ( activateAuxiliary ) {
535+ state . isAuxiliaryActive = true ;
536+ } else if ( activate ) {
535537 const gestureState = createGestureState (
536538 context ,
537539 props ,
@@ -544,8 +546,6 @@ const responderImpl = {
544546 state . initialPosition . x = gestureState . x ;
545547 state . initialPosition . y = gestureState . y ;
546548 dispatchStart ( context , props , state ) ;
547- } else if ( activateAuxiliary ) {
548- state . isAuxiliaryActive = true ;
549549 }
550550 }
551551 break ;
@@ -611,7 +611,7 @@ const responderImpl = {
611611 if ( state . isActive && isActivePointer ( event , state ) ) {
612612 state . gestureState = createGestureState ( context , props , state , event ) ;
613613 state . isActive = false ;
614- if ( isAuxiliary ( state . buttons , nativeEvent ) ) {
614+ if ( isAuxiliary ( state . buttons , event ) ) {
615615 dispatchCancel ( context , props , state ) ;
616616 dispatchAuxiliaryTap ( context , props , state ) ;
617617 // Remove the root events here as no 'click' event is dispatched
@@ -626,7 +626,7 @@ const responderImpl = {
626626 }
627627 } else if (
628628 state . isAuxiliaryActive &&
629- isAuxiliary ( state . buttons , nativeEvent )
629+ isAuxiliary ( state . buttons , event )
630630 ) {
631631 state . isAuxiliaryActive = false ;
632632 state . gestureState = createGestureState ( context , props , state , event ) ;
0 commit comments