@@ -493,6 +493,7 @@ describe('CdkDrag', () => {
493
493
expect ( dragElement . style . touchAction )
494
494
. not . toEqual ( 'none' , 'should not disable touchAction on when there is a drag handle' ) ;
495
495
} ) ;
496
+
496
497
it ( 'should be able to reset a freely-dragged item to its initial position' , fakeAsync ( ( ) => {
497
498
const fixture = createComponent ( StandaloneDraggable ) ;
498
499
fixture . detectChanges ( ) ;
@@ -1760,6 +1761,31 @@ describe('CdkDrag', () => {
1760
1761
. toEqual ( [ 'Zero' , 'One' , 'Two' , 'Three' ] ) ;
1761
1762
} ) ) ;
1762
1763
1764
+ it ( 'should not move the item if the group is disabled' , fakeAsync ( ( ) => {
1765
+ const fixture = createComponent ( ConnectedDropZonesViaGroupDirective ) ;
1766
+ fixture . detectChanges ( ) ;
1767
+ const dragItems = fixture . componentInstance . groupedDragItems [ 0 ] ;
1768
+
1769
+ fixture . componentInstance . groupDisabled = true ;
1770
+ fixture . detectChanges ( ) ;
1771
+
1772
+ expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
1773
+ . toEqual ( [ 'Zero' , 'One' , 'Two' , 'Three' ] ) ;
1774
+
1775
+ const firstItem = dragItems [ 0 ] ;
1776
+ const thirdItemRect = dragItems [ 2 ] . element . nativeElement . getBoundingClientRect ( ) ;
1777
+
1778
+ dragElementViaMouse ( fixture , firstItem . element . nativeElement ,
1779
+ thirdItemRect . right + 1 , thirdItemRect . top + 1 ) ;
1780
+ flush ( ) ;
1781
+ fixture . detectChanges ( ) ;
1782
+
1783
+ expect ( fixture . componentInstance . droppedSpy ) . not . toHaveBeenCalled ( ) ;
1784
+
1785
+ expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
1786
+ . toEqual ( [ 'Zero' , 'One' , 'Two' , 'Three' ] ) ;
1787
+ } ) ) ;
1788
+
1763
1789
} ) ;
1764
1790
1765
1791
describe ( 'in a connected drop container' , ( ) => {
@@ -2501,7 +2527,7 @@ class ConnectedDropZones implements AfterViewInit {
2501
2527
}
2502
2528
` ] ,
2503
2529
template : `
2504
- <div cdkDropListGroup>
2530
+ <div cdkDropListGroup [cdkDropListGroupDisabled]="groupDisabled" >
2505
2531
<div
2506
2532
cdkDropList
2507
2533
[cdkDropListData]="todo"
@@ -2518,7 +2544,9 @@ class ConnectedDropZones implements AfterViewInit {
2518
2544
</div>
2519
2545
`
2520
2546
} )
2521
- class ConnectedDropZonesViaGroupDirective extends ConnectedDropZones { }
2547
+ class ConnectedDropZonesViaGroupDirective extends ConnectedDropZones {
2548
+ groupDisabled = false ;
2549
+ }
2522
2550
2523
2551
2524
2552
@Component ( {
0 commit comments