@@ -50,11 +50,7 @@ export const SelectionHandler = (
5050
5151 let lastDownEvent : Selection [ 'event' ] | undefined ;
5252
53- let isContextMenuOpen = false ;
54-
5553 const onSelectStart = ( evt : Event ) => {
56- isContextMenuOpen = false ;
57-
5854 if ( isLeftClick === false )
5955 return ;
6056
@@ -161,8 +157,6 @@ export const SelectionHandler = (
161157 * to the initial pointerdown event and remember the button
162158 */
163159 const onPointerDown = ( evt : PointerEvent ) => {
164- if ( isContextMenuOpen ) return ;
165-
166160 if ( isNotAnnotatable ( evt . target as Node ) ) return ;
167161
168162 /**
@@ -188,8 +182,6 @@ export const SelectionHandler = (
188182 }
189183
190184 const onPointerUp = ( evt : PointerEvent ) => {
191- if ( isContextMenuOpen ) return ;
192-
193185 if ( isNotAnnotatable ( evt . target as Node ) || ! isLeftClick ) return ;
194186
195187 // Logic for selecting an existing annotation
@@ -239,8 +231,6 @@ export const SelectionHandler = (
239231 }
240232
241233 const onContextMenu = ( evt : PointerEvent ) => {
242- isContextMenuOpen = true ;
243-
244234 const sel = document . getSelection ( ) ;
245235
246236 if ( sel ?. isCollapsed ) return ;
@@ -282,15 +272,15 @@ export const SelectionHandler = (
282272
283273 selection . userSelect ( currentTarget . annotation , cloneKeyboardEvent ( evt ) ) ;
284274 }
285-
275+
286276 document . removeEventListener ( 'selectionchange' , onSelected ) ;
287277
288278 // Sigh... this needs a delay to work. But doesn't seem reliable.
289279 } , 100 ) ;
290280
291281 // Listen to the change event that follows
292282 document . addEventListener ( 'selectionchange' , onSelected ) ;
293-
283+
294284 // Start selection!
295285 onSelectStart ( evt ) ;
296286 }
0 commit comments