File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,19 @@ describe("sidebar pointer lifecycle", () => {
7878 expect ( drag . onFinish ) . toHaveBeenCalledOnce ( ) ;
7979 } ) ;
8080
81+ it ( "exposes the activating move before drag start and ignores other pointers" , ( ) => {
82+ const drag = gesture ( ) ;
83+ drag . onStart . mockImplementation ( ( ) => {
84+ expect ( drag . sensor . currentCoordinates ) . toEqual ( { x : 400 , y : 50 } ) ;
85+ } ) ;
86+ document . dispatchEvent ( pointer ( "pointermove" , { clientX : 400 , clientY : 50 } ) ) ;
87+ expect ( drag . onStart ) . toHaveBeenCalledOnce ( ) ;
88+ document . dispatchEvent ( pointer ( "pointermove" , { pointerId : 2 , clientX : 900 } ) ) ;
89+ expect ( drag . sensor . currentCoordinates ) . toEqual ( { x : 400 , y : 50 } ) ;
90+ document . dispatchEvent ( pointer ( "pointerup" , { buttons : 0 } ) ) ;
91+ expect ( drag . onEnd ) . toHaveBeenCalledOnce ( ) ;
92+ } ) ;
93+
8194 const interruptions = {
8295 blur : ( ) => window . dispatchEvent ( new Event ( "blur" ) ) ,
8396 hidden : ( ) => {
Original file line number Diff line number Diff line change @@ -25,13 +25,15 @@ export class SidebarPointerSensor {
2525 } ,
2626 ] ;
2727 autoScrollEnabled = true ;
28+ currentCoordinates : { x : number ; y : number } ;
2829 private phase : "pending" | "dragging" | "finished" = "pending" ;
2930 private readonly pointer : PointerEvent ;
3031 private readonly document : Document ;
3132 private readonly window : Window ;
3233
3334 constructor ( private readonly props : SensorProps < Options > ) {
3435 this . pointer = props . event as PointerEvent ;
36+ this . currentCoordinates = this . coordinates ( ) ;
3537 this . document = getOwnerDocument ( this . pointer . target ) ;
3638 this . window = getWindow ( this . pointer . target ) ;
3739 this . document . addEventListener ( "pointermove" , this . move , { passive : false , capture : true } ) ;
@@ -66,6 +68,7 @@ export class SidebarPointerSensor {
6668 // a drag when the initiating button is no longer held.
6769 if ( ( event . buttons & 1 ) === 0 ) return this . cancel ( ) ;
6870 const coordinates = { x : event . clientX , y : event . clientY } ;
71+ this . currentCoordinates = coordinates ;
6972 if ( this . phase === "pending" ) {
7073 const offset = {
7174 x : event . clientX - this . pointer . clientX ,
Original file line number Diff line number Diff line change @@ -3325,10 +3325,7 @@ export default function Sidebar() {
33253325 // splits the view instead of reordering the list.
33263326 const thread = threadByKeyRef . current . get ( activeKey ) ;
33273327 if ( thread && ! isMobile ) {
3328- chatPaneDragPointer . current =
3329- event . activatorEvent instanceof PointerEvent
3330- ? { x : event . activatorEvent . clientX , y : event . activatorEvent . clientY }
3331- : null ;
3328+ chatPaneDragPointer . current = dragSensorRef . current ?. currentCoordinates ?? null ;
33323329 useChatPaneDragStore . getState ( ) . start ( {
33333330 threadRef : scopeThreadRef ( thread . environmentId , thread . id ) ,
33343331 title : thread . title ,
You can’t perform that action at this time.
0 commit comments