1
- import { useRef , useState } from 'react' ;
1
+ import { useState } from 'react' ;
2
2
import { css } from '@linaria/core' ;
3
3
4
4
import { useRovingTabIndex } from './hooks' ;
@@ -85,7 +85,6 @@ export default function HeaderCell<R, SR>({
85
85
direction,
86
86
dragDropKey
87
87
} : HeaderCellProps < R , SR > ) {
88
- const hasDoubleClickedRef = useRef ( false ) ;
89
88
const [ isDragging , setIsDragging ] = useState ( false ) ;
90
89
const [ isOver , setIsOver ] = useState ( false ) ;
91
90
const isRtl = direction === 'rtl' ;
@@ -120,8 +119,6 @@ export default function HeaderCell<R, SR>({
120
119
const headerCell = currentTarget . parentElement ! ;
121
120
const { right, left } = headerCell . getBoundingClientRect ( ) ;
122
121
const offset = isRtl ? event . clientX - left : right - event . clientX ;
123
- hasDoubleClickedRef . current = false ;
124
-
125
122
function onPointerMove ( event : PointerEvent ) {
126
123
const { width, right, left } = headerCell . getBoundingClientRect ( ) ;
127
124
let newWidth = isRtl ? right + offset - event . clientX : event . clientX + offset - left ;
@@ -131,24 +128,19 @@ export default function HeaderCell<R, SR>({
131
128
}
132
129
}
133
130
134
- function onLostPointerCapture ( event : PointerEvent ) {
135
- // Handle final pointer position that may have been skipped by coalesced pointer move events.
136
- // Skip move pointer handling if the user double-clicked.
137
- if ( ! hasDoubleClickedRef . current ) {
138
- onPointerMove ( event ) ;
139
- }
140
-
131
+ function onLostPointerCapture ( ) {
141
132
currentTarget . removeEventListener ( 'pointermove' , onPointerMove ) ;
142
133
currentTarget . removeEventListener ( 'lostpointercapture' , onLostPointerCapture ) ;
143
134
}
144
135
145
136
currentTarget . setPointerCapture ( pointerId ) ;
146
137
currentTarget . addEventListener ( 'pointermove' , onPointerMove ) ;
138
+ // we are not using pointerup because it does not fire in some cases
139
+ // pointer down -> alt+tab -> pointer up over another window -> pointerup event not fired
147
140
currentTarget . addEventListener ( 'lostpointercapture' , onLostPointerCapture ) ;
148
141
}
149
142
150
143
function onDoubleClick ( ) {
151
- hasDoubleClickedRef . current = true ;
152
144
onColumnResize ( column , 'max-content' ) ;
153
145
}
154
146
0 commit comments