@@ -106,12 +106,6 @@ export const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {
106106 } ;
107107 } , [ update ] ) ;
108108
109- // Prevent text-annotator from handling the irrelevant events triggered from the popup
110- const getStopEventsPropagationProps = useCallback (
111- ( ) => ( { onPointerUp : ( event : PointerEvent < HTMLDivElement > ) => event . stopPropagation ( ) } ) ,
112- [ ]
113- ) ;
114-
115109 // Don't shift focus to the floating element if selected via keyboard or on mobile.
116110 const initialFocus = useMemo ( ( ) => {
117111 return ( event ?. type === 'keyup' || event ?. type === 'contextmenu' || isMobile ( ) ) ? - 1 : 0 ;
@@ -131,8 +125,7 @@ export const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {
131125 className = "a9s-popup r6o-popup annotation-popup r6o-text-popup not-annotatable"
132126 ref = { refs . setFloating }
133127 style = { floatingStyles }
134- { ...getFloatingProps ( ) }
135- { ...getStopEventsPropagationProps ( ) } >
128+ { ...getFloatingProps ( getStopEventsPropagationProps ( ) ) } >
136129 { props . popup ( {
137130 annotation : selected [ 0 ] . annotation ,
138131 editable : selected [ 0 ] . editable ,
@@ -148,3 +141,14 @@ export const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {
148141 ) : null ;
149142
150143}
144+
145+ /**
146+ * Prevent text-annotator from handling the irrelevant events
147+ * triggered from the popup/toolbar/dialog
148+ */
149+ const getStopEventsPropagationProps = < T extends HTMLElement = HTMLElement > ( ) => ( {
150+ onPointerUp : ( event : PointerEvent < T > ) => event . stopPropagation ( ) ,
151+ onPointerDown : ( event : PointerEvent < T > ) => event . stopPropagation ( ) ,
152+ onMouseDown : ( event : MouseEvent < T > ) => event . stopPropagation ( ) ,
153+ onMouseUp : ( event : MouseEvent < T > ) => event . stopPropagation ( )
154+ } ) ;
0 commit comments