@@ -94,12 +94,6 @@ export const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {
9494    } 
9595  } ,  [ isOpen ,  annotation ,  refs ] ) ; 
9696
97-   // Prevent text-annotator from handling the irrelevant events triggered from the popup 
98-   const  getStopEventsPropagationProps  =  useCallback ( 
99-     ( )  =>  ( {  onPointerUp : ( event : PointerEvent < HTMLDivElement > )  =>  event . stopPropagation ( )  } ) , 
100-     [ ] 
101-   ) ; 
102- 
10397  useEffect ( ( )  =>  { 
10498    const  config : MutationObserverInit  =  {  attributes : true ,  childList : true ,  subtree : true  } ; 
10599
@@ -114,11 +108,19 @@ export const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {
114108    } ; 
115109  } ,  [ update ] ) ; 
116110
111+   // Prevent text-annotator from handling the irrelevant events triggered from the popup 
112+   const  getStopEventsPropagationProps  =  useCallback ( 
113+     ( )  =>  ( {  onPointerUp : ( event : PointerEvent < HTMLDivElement > )  =>  event . stopPropagation ( )  } ) , 
114+     [ ] 
115+   ) ; 
116+ 
117117  // Don't shift focus to the floating element if selected via keyboard or on mobile. 
118118  const  initialFocus  =  useMemo ( ( )  =>  { 
119119    return  ( event ?. type  ===  'keyup'  ||  event ?. type  ===  'contextmenu'  ||  isMobile ( ) )  ? - 1  : 0 ; 
120120  } ,  [ event ] ) ; 
121121
122+   const  onClose  =  ( )  =>  r ?. cancelSelected ( ) ; 
123+ 
122124  return  isOpen  &&  selected . length  >  0  ? ( 
123125    < FloatingPortal > 
124126      < FloatingFocusManager 
@@ -139,9 +141,9 @@ export const TextAnnotatorPopup = (props: TextAnnotationPopupProps) => {
139141            event
140142          } ) } 
141143
142-           < span  className = "r6o-popup-sr-only"  aria-live = "assertive" > 
143-             { props . ariaCloseWarning  ||  'This dialog will close when you leave  it.' } 
144-           </ span > 
144+           < button  className = "r6o-popup-sr-only"  aria-live = "assertive"   onClick = { onClose } > 
145+             { props . ariaCloseWarning  ||  'Click or leave this dialog to close  it.' } 
146+           </ button > 
145147        </ div > 
146148      </ FloatingFocusManager > 
147149    </ FloatingPortal > 
0 commit comments