File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -2640,6 +2640,23 @@ describe('CdkDrag', () => {
2640
2640
} ) . not . toThrow ( ) ;
2641
2641
} ) ) ;
2642
2642
2643
+ it ( 'should not be able to start a drag sequence while another one is still active' ,
2644
+ fakeAsync ( ( ) => {
2645
+ const fixture = createComponent ( DraggableInDropZone ) ;
2646
+ fixture . detectChanges ( ) ;
2647
+ const [ item , otherItem ] = fixture . componentInstance . dragItems . toArray ( ) ;
2648
+
2649
+ startDraggingViaMouse ( fixture , item . element . nativeElement ) ;
2650
+
2651
+ expect ( document . querySelectorAll ( '.cdk-drag-dragging' ) . length )
2652
+ . toBe ( 1 , 'Expected one item to be dragged initially.' ) ;
2653
+
2654
+ startDraggingViaMouse ( fixture , otherItem . element . nativeElement ) ;
2655
+
2656
+ expect ( document . querySelectorAll ( '.cdk-drag-dragging' ) . length )
2657
+ . toBe ( 1 , 'Expected only one item to continue to be dragged.' ) ;
2658
+ } ) ) ;
2659
+
2643
2660
} ) ;
2644
2661
2645
2662
describe ( 'in a connected drop container' , ( ) => {
Original file line number Diff line number Diff line change @@ -510,8 +510,13 @@ export class DragRef<T = any> {
510
510
// in the `pointerMove` subscription, because we're not guaranteed to have one move event
511
511
// per pixel of movement (e.g. if the user moves their pointer quickly).
512
512
if ( isOverThreshold && ( Date . now ( ) >= this . _dragStartTime + ( this . dragStartDelay || 0 ) ) ) {
513
- this . _hasStartedDragging = true ;
514
- this . _ngZone . run ( ( ) => this . _startDragSequence ( event ) ) ;
513
+ // Prevent other drag sequences from starting while something in the container is still
514
+ // being dragged. This can happen while we're waiting for the drop animation to finish
515
+ // and can cause errors, because some elements might still be moving around.
516
+ if ( ! this . _dropContainer || ! this . _dropContainer . isDragging ( ) ) {
517
+ this . _hasStartedDragging = true ;
518
+ this . _ngZone . run ( ( ) => this . _startDragSequence ( event ) ) ;
519
+ }
515
520
}
516
521
517
522
return ;
You can’t perform that action at this time.
0 commit comments