@@ -637,6 +637,8 @@ class AnnotationEditorUIManager {
637637
638638 #isEnabled = false ;
639639
640+ #isPointerDown = false ;
641+
640642 #isWaiting = false ;
641643
642644 #keyboardManagerAC = null ;
@@ -857,6 +859,20 @@ class AnnotationEditorUIManager {
857859 evt => this . updateParams ( evt . type , evt . value ) ,
858860 { signal }
859861 ) ;
862+ window . addEventListener (
863+ "pointerdown" ,
864+ ( ) => {
865+ this . #isPointerDown = true ;
866+ } ,
867+ { capture : true , signal }
868+ ) ;
869+ window . addEventListener (
870+ "pointerup" ,
871+ ( ) => {
872+ this . #isPointerDown = false ;
873+ } ,
874+ { capture : true , signal }
875+ ) ;
860876 this . #addSelectionListener( ) ;
861877 this . #addDragAndDropListeners( ) ;
862878 this . #addKeyboardManager( ) ;
@@ -1299,22 +1315,30 @@ class AnnotationEditorUIManager {
12991315 : null ;
13001316 activeLayer ?. toggleDrawing ( ) ;
13011317
1302- const ac = new AbortController ( ) ;
1303- const signal = this . combinedSignal ( ac ) ;
1318+ if ( this . #isPointerDown) {
1319+ const ac = new AbortController ( ) ;
1320+ const signal = this . combinedSignal ( ac ) ;
13041321
1305- const pointerup = e => {
1306- if ( e . type === "pointerup" && e . button !== 0 ) {
1307- // Do nothing on right click.
1308- return ;
1309- }
1310- ac . abort ( ) ;
1322+ const pointerup = e => {
1323+ if ( e . type === "pointerup" && e . button !== 0 ) {
1324+ // Do nothing on right click.
1325+ return ;
1326+ }
1327+ ac . abort ( ) ;
1328+ activeLayer ?. toggleDrawing ( true ) ;
1329+ if ( e . type === "pointerup" ) {
1330+ this . #onSelectEnd( "main_toolbar" ) ;
1331+ }
1332+ } ;
1333+ window . addEventListener ( "pointerup" , pointerup , { signal } ) ;
1334+ window . addEventListener ( "blur" , pointerup , { signal } ) ;
1335+ } else {
1336+ // Here neither the shift key nor the pointer is down and we've
1337+ // something in the selection: we can be in the case where the user is
1338+ // using a screen reader (see bug 1976597).
13111339 activeLayer ?. toggleDrawing ( true ) ;
1312- if ( e . type === "pointerup" ) {
1313- this . #onSelectEnd( "main_toolbar" ) ;
1314- }
1315- } ;
1316- window . addEventListener ( "pointerup" , pointerup , { signal } ) ;
1317- window . addEventListener ( "blur" , pointerup , { signal } ) ;
1340+ this . #onSelectEnd( "main_toolbar" ) ;
1341+ }
13181342 }
13191343 }
13201344
0 commit comments