@@ -147,46 +147,65 @@ describe('Example - Frozen Columns - Column Header Reorder (characterization)',
147147 cy . get ( RIGHT_VIEWPORT ) . scrollTo ( 0 , 0 , { ensureScrollable : false } ) ;
148148 } ) ;
149149
150- it ( 'should auto-scroll the right viewport when a header drag starts beyond the right edge of the grid' , ( ) => {
150+ it ( 'should auto-scroll the right viewport when a header drag moves past the right edge of the grid' , ( ) => {
151151 cy . get ( RIGHT_VIEWPORT ) . scrollTo ( 0 , 0 , { ensureScrollable : false } ) ;
152152 cy . wait ( 50 ) ;
153153 cy . get ( RIGHT_VIEWPORT ) . should ( ( $v ) => expect ( $v [ 0 ] . scrollLeft ) . to . eq ( 0 ) ) ;
154154
155- // start a drag on "Finish" with the pointer already past the grid's right edge, then also fire a
156- // document-level `drag` event at those coordinates (that is what a real browser does continuously
157- // during a native drag, and what the future native reorder engine listens to for auto-scrolling)
155+ // Start the drag inside the viewport first, then move past the grid's right edge via document-level
156+ // drag events. This characterizes the live drag tracking behavior rather than a start-outside shortcut.
158157 cy . window ( ) . then ( ( win : any ) => {
159158 const finishHeader = getRightHeader ( win , 'Finish' ) ;
160159 expect ( finishHeader ) . to . exist ;
161160 const rect = finishHeader . getBoundingClientRect ( ) ;
161+ const startX = rect . left + rect . width / 2 ;
162162 const sy = rect . top + rect . height / 2 ;
163- const dragX = ( win . document . querySelector ( '#myGrid' ) as HTMLElement ) . clientWidth + 100 ;
164163 const dataTransfer = new DataTransfer ( ) ;
165164
166- pressPointer ( finishHeader , rect . left + rect . width / 2 , sy ) ;
167- finishHeader . dispatchEvent ( createDragLikeEvent ( 'dragstart' , dragX , sy , dataTransfer ) ) ;
168- win . document . dispatchEvent ( createDragLikeEvent ( 'drag' , dragX , sy , dataTransfer ) ) ;
165+ pressPointer ( finishHeader , startX , sy ) ;
166+ finishHeader . dispatchEvent ( createDragLikeEvent ( 'dragstart' , startX , sy , dataTransfer ) ) ;
169167 } ) ;
170168
171- cy . wait ( 250 ) ;
169+ // SortableJS dispatches its start callback on the next macrotask. Yield so the
170+ // grid can bind its document-level auto-scroll listeners before moving outside.
171+ cy . wait ( 50 ) ;
172172 cy . window ( ) . then ( ( win : any ) => {
173173 const finishHeader = getRightHeader ( win , 'Finish' ) ;
174- const sy = finishHeader . getBoundingClientRect ( ) . top ;
175- const dragX = ( win . document . querySelector ( '#myGrid' ) as HTMLElement ) . clientWidth + 100 ;
176- win . document . dispatchEvent ( createDragLikeEvent ( 'drag' , dragX , sy , new DataTransfer ( ) ) ) ;
174+ const rect = finishHeader . getBoundingClientRect ( ) ;
175+ const gridRect = ( win . document . querySelector ( '#myGrid' ) as HTMLElement ) . getBoundingClientRect ( ) ;
176+ const sy = rect . top + rect . height / 2 ;
177+ const dragX = gridRect . right + 100 ;
178+ const dataTransfer = new DataTransfer ( ) ;
179+ win . document . dispatchEvent ( createDragLikeEvent ( 'drag' , dragX , sy , dataTransfer ) ) ;
180+ win . document . dispatchEvent ( createDragLikeEvent ( 'mousemove' , dragX , sy , dataTransfer ) ) ;
177181 } ) ;
178182 cy . wait ( 250 ) ;
179183
180- cy . get ( RIGHT_VIEWPORT ) . should ( ( $v ) => expect ( $v [ 0 ] . scrollLeft ) . to . be . greaterThan ( 10 ) ) ;
184+ cy . window ( ) . then ( ( win : any ) => {
185+ const finishHeader = getRightHeader ( win , 'Finish' ) ;
186+ const rect = finishHeader . getBoundingClientRect ( ) ;
187+ const sy = rect . top + rect . height / 2 ;
188+ const safeX = rect . left + rect . width / 2 ;
189+ const dataTransfer = new DataTransfer ( ) ;
190+ win . document . dispatchEvent ( createDragLikeEvent ( 'drag' , safeX , sy , dataTransfer ) ) ;
191+ win . document . dispatchEvent ( createDragLikeEvent ( 'mousemove' , safeX , sy , dataTransfer ) ) ;
192+ } ) ;
193+
194+ cy . get ( RIGHT_VIEWPORT ) . then ( ( $v ) => {
195+ expect ( $v [ 0 ] . scrollLeft ) . to . be . greaterThan ( 10 ) ;
196+ const scrollLeftAfterSafeZone = $v [ 0 ] . scrollLeft ;
197+ cy . wait ( 250 ) ;
198+ cy . get ( RIGHT_VIEWPORT ) . should ( ( $v2 ) => expect ( $v2 [ 0 ] . scrollLeft ) . to . eq ( scrollLeftAfterSafeZone ) ) ;
199+ } ) ;
181200
182- // end the drag on the source itself: no reorder, and the auto-scroll must stop
201+ // end the drag on the source itself: no reorder, and the auto-scroll must remain stopped
183202 cy . window ( ) . then ( ( win : any ) => {
184203 const finishHeader = getRightHeader ( win , 'Finish' ) ;
185204 const rect = finishHeader . getBoundingClientRect ( ) ;
186205 const sy = rect . top + rect . height / 2 ;
187- const dragX = ( win . document . querySelector ( '#myGrid' ) as HTMLElement ) . clientWidth + 100 ;
188- finishHeader . dispatchEvent ( createDragLikeEvent ( 'dragend' , dragX , sy , new DataTransfer ( ) ) ) ;
189- releasePointer ( finishHeader , dragX , sy ) ;
206+ const safeX = rect . left + rect . width / 2 ;
207+ finishHeader . dispatchEvent ( createDragLikeEvent ( 'dragend' , safeX , sy , new DataTransfer ( ) ) ) ;
208+ releasePointer ( finishHeader , safeX , sy ) ;
190209 } ) ;
191210
192211 cy . get ( RIGHT_VIEWPORT ) . then ( ( $v ) => {
0 commit comments