@@ -10,7 +10,7 @@ import { useSkillReferenceAutocomplete } from '../hooks/useSkillReferenceAutocom
1010import { HumanOnlySkillNotice , SkillReferenceMenu } from './SkillReferenceMenu' ;
1111import type { SkillReferenceToken } from '../utils/skillReferences' ;
1212import {
13- hasCoarsePointer ,
13+ hasPrimaryCoarsePointer ,
1414 shouldUseExpandedComposer ,
1515 useVisibleViewportBounds ,
1616 type VisibleViewportBounds ,
@@ -165,7 +165,7 @@ export const CommentPopover: React.FC<CommentPopoverProps> = ({
165165 yieldState,
166166} ) => {
167167 const visibleBounds = useVisibleViewportBounds ( 16 ) ;
168- const coarsePointer = hasCoarsePointer ( ) ;
168+ const coarsePointer = hasPrimaryCoarsePointer ( ) ;
169169 const prefersExpandedComposer = shouldUseExpandedComposer ( {
170170 bounds : visibleBounds ,
171171 coarsePointer,
@@ -293,17 +293,20 @@ export const CommentPopover: React.FC<CommentPopoverProps> = ({
293293 } ) ;
294294 } , [ ] ) ;
295295
296- const handleClose = useCallback ( ( ) => {
297- if ( draftKey ) {
298- if ( hasUnsavedCommentContent ( text , allowImages ? images : [ ] ) ) {
299- draftStore . set ( draftKey , { text, images : allowImages ? images : [ ] } ) ;
300- } else {
301- draftStore . delete ( draftKey ) ;
296+ const handleClose = useCallback (
297+ ( focusDisposition : 'restore-opener' | 'preserve-pointer-target' = 'restore-opener' ) => {
298+ if ( draftKey ) {
299+ if ( hasUnsavedCommentContent ( text , allowImages ? images : [ ] ) ) {
300+ draftStore . set ( draftKey , { text, images : allowImages ? images : [ ] } ) ;
301+ } else {
302+ draftStore . delete ( draftKey ) ;
303+ }
302304 }
303- }
304- onClose ( ) ;
305- restoreOpeningFocus ( ) ;
306- } , [ allowImages , draftKey , images , onClose , restoreOpeningFocus , text ] ) ;
305+ onClose ( ) ;
306+ if ( focusDisposition === 'restore-opener' ) restoreOpeningFocus ( ) ;
307+ } ,
308+ [ allowImages , draftKey , images , onClose , restoreOpeningFocus , text ] ,
309+ ) ;
307310
308311 // Click-outside for popover mode
309312 useEffect ( ( ) => {
@@ -322,7 +325,7 @@ export const CommentPopover: React.FC<CommentPopoverProps> = ({
322325 // Preserve the existing draft so the following Shift-click can extend
323326 // it instead of silently replacing it with a new one.
324327 if ( shiftSelectionActive && e . shiftKey ) return ;
325- handleClose ( ) ;
328+ handleClose ( 'preserve-pointer-target' ) ;
326329 } ;
327330
328331 document . addEventListener ( 'pointerdown' , handlePointerDown , true ) ;
@@ -512,7 +515,7 @@ export const CommentPopover: React.FC<CommentPopoverProps> = ({
512515 type = "button"
513516 aria-label = "Dismiss comment"
514517 className = "absolute inset-0 bg-background/80 backdrop-blur-sm"
515- onClick = { handleClose }
518+ onClick = { ( ) => handleClose ( ) }
516519 />
517520
518521 { /* Dialog card */ }
@@ -561,7 +564,7 @@ export const CommentPopover: React.FC<CommentPopoverProps> = ({
561564 </ button >
562565 ) }
563566 < button
564- onClick = { handleClose }
567+ onClick = { ( ) => handleClose ( ) }
565568 className = "p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors"
566569 title = "Close"
567570 >
@@ -706,7 +709,7 @@ export const CommentPopover: React.FC<CommentPopoverProps> = ({
706709 < ExpandIcon />
707710 </ button >
708711 < button
709- onClick = { handleClose }
712+ onClick = { ( ) => handleClose ( ) }
710713 className = "p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors"
711714 title = "Close"
712715 >
0 commit comments