1- import { useRef , useState } from 'react' ;
1+ import { useState } from 'react' ;
22import { css } from '@linaria/core' ;
33
44import { useRovingTabIndex } from './hooks' ;
@@ -84,7 +84,6 @@ export default function HeaderCell<R, SR>({
8484 direction,
8585 dragDropKey
8686} : HeaderCellProps < R , SR > ) {
87- const hasDoubleClickedRef = useRef ( false ) ;
8887 const [ isDragging , setIsDragging ] = useState ( false ) ;
8988 const [ isOver , setIsOver ] = useState ( false ) ;
9089 const isRtl = direction === 'rtl' ;
@@ -119,8 +118,6 @@ export default function HeaderCell<R, SR>({
119118 const headerCell = currentTarget . parentElement ! ;
120119 const { right, left } = headerCell . getBoundingClientRect ( ) ;
121120 const offset = isRtl ? event . clientX - left : right - event . clientX ;
122- hasDoubleClickedRef . current = false ;
123-
124121 function onPointerMove ( event : PointerEvent ) {
125122 const { width, right, left } = headerCell . getBoundingClientRect ( ) ;
126123 const newWidth = isRtl ? right + offset - event . clientX : event . clientX + offset - left ;
@@ -129,24 +126,19 @@ export default function HeaderCell<R, SR>({
129126 }
130127 }
131128
132- function onLostPointerCapture ( event : PointerEvent ) {
133- // Handle final pointer position that may have been skipped by coalesced pointer move events.
134- // Skip move pointer handling if the user double-clicked.
135- if ( ! hasDoubleClickedRef . current ) {
136- onPointerMove ( event ) ;
137- }
138-
129+ function onLostPointerCapture ( ) {
139130 currentTarget . removeEventListener ( 'pointermove' , onPointerMove ) ;
140131 currentTarget . removeEventListener ( 'lostpointercapture' , onLostPointerCapture ) ;
141132 }
142133
143134 currentTarget . setPointerCapture ( pointerId ) ;
144135 currentTarget . addEventListener ( 'pointermove' , onPointerMove ) ;
136+ // we are not using pointerup because it does not fire in some cases
137+ // pointer down -> alt+tab -> pointer up over another window -> pointerup event not fired
145138 currentTarget . addEventListener ( 'lostpointercapture' , onLostPointerCapture ) ;
146139 }
147140
148141 function onDoubleClick ( ) {
149- hasDoubleClickedRef . current = true ;
150142 onColumnResize ( column , 'max-content' ) ;
151143 }
152144
0 commit comments