@@ -48,6 +48,7 @@ function press(target: HTMLElement, from: { x: number; y: number }, to = from) {
4848 fireEvent . pointerDown ( target , {
4949 pointerId : 1 ,
5050 button : 0 ,
51+ isPrimary : true ,
5152 clientX : from . x ,
5253 clientY : from . y ,
5354 } ) ;
@@ -726,7 +727,7 @@ it("does not zoom any gallery image with a press held across navigation", () =>
726727 const image = screen . getByRole ( "img" , { name : "Attachment preview" } ) ;
727728 const stage = image . parentElement ;
728729 if ( ! stage ) throw new Error ( "Missing stage" ) ;
729- fireEvent . pointerDown ( image , { pointerId : 1 , button : 0 } ) ;
730+ fireEvent . pointerDown ( image , { pointerId : 1 , button : 0 , isPrimary : true } ) ;
730731 fireEvent . click ( screen . getByRole ( "button" , { name : "Next image" } ) ) ;
731732 expect ( screen . getByText ( "2 / 3" ) ) . toBeVisible ( ) ;
732733 fireEvent . pointerUp ( stage , { pointerId : 1 } ) ;
@@ -737,6 +738,7 @@ it("does not zoom any gallery image with a press held across navigation", () =>
737738 {
738739 pointerId : 1 ,
739740 button : 0 ,
741+ isPrimary : true ,
740742 } ,
741743 ) ;
742744 fireEvent . click ( screen . getByRole ( "button" , { name : "Previous image" } ) ) ;
@@ -760,7 +762,12 @@ it.each([
760762 ( _ , order ) => {
761763 const { stage, image } = setup ( ) ;
762764 for ( const pointerId of [ 1 , 2 ] )
763- fireEvent . pointerDown ( image , { pointerId, button : 0 , clientX : 250 } ) ;
765+ fireEvent . pointerDown ( image , {
766+ pointerId,
767+ button : 0 ,
768+ isPrimary : pointerId === 1 ,
769+ clientX : 250 ,
770+ } ) ;
764771 for ( const pointerId of order )
765772 fireEvent . pointerUp ( stage , { pointerId, clientX : 250 } ) ;
766773 expect ( percent ( ) ) . toBe ( "100%" ) ;
@@ -769,15 +776,41 @@ it.each([
769776 } ,
770777) ;
771778
779+ it ( "does not click-zoom a non-primary image contact without a stage-owned press" , ( ) => {
780+ const { stage, image } = setup ( ) ;
781+ // The primary contact may be on the toolbar or outside this stage.
782+ fireEvent . pointerDown ( image , {
783+ pointerId : 2 ,
784+ button : 0 ,
785+ isPrimary : false ,
786+ clientX : 250 ,
787+ clientY : 200 ,
788+ } ) ;
789+ fireEvent . pointerUp ( stage , { pointerId : 2 , clientX : 250 , clientY : 200 } ) ;
790+ expect ( percent ( ) ) . toBe ( "100%" ) ;
791+ press ( image , { x : 250 , y : 200 } ) ;
792+ expect ( percent ( ) ) . toBe ( "200%" ) ;
793+ } ) ;
794+
772795it . each ( [ "pointerCancel" , "lostPointerCapture" ] as const ) (
773796 "ends only the owning press on %s" ,
774797 ( type ) => {
775798 const { stage, image } = setup ( ) ;
776- fireEvent . pointerDown ( image , { pointerId : 1 , button : 0 , clientX : 250 } ) ;
799+ fireEvent . pointerDown ( image , {
800+ pointerId : 1 ,
801+ button : 0 ,
802+ isPrimary : true ,
803+ clientX : 250 ,
804+ } ) ;
777805 fireEvent [ type ] ( stage , { pointerId : 2 } ) ;
778806 fireEvent . pointerUp ( stage , { pointerId : 1 , clientX : 250 } ) ;
779807 expect ( percent ( ) ) . toBe ( "200%" ) ;
780- fireEvent . pointerDown ( image , { pointerId : 1 , button : 0 , clientX : 250 } ) ;
808+ fireEvent . pointerDown ( image , {
809+ pointerId : 1 ,
810+ button : 0 ,
811+ isPrimary : true ,
812+ clientX : 250 ,
813+ } ) ;
781814 fireEvent [ type ] ( stage , { pointerId : 1 } ) ;
782815 fireEvent . pointerUp ( stage , { pointerId : 1 , clientX : 250 } ) ;
783816 expect ( percent ( ) ) . toBe ( "200%" ) ;
0 commit comments