@@ -1916,7 +1916,31 @@ describe('CdkDrag', () => {
19161916 dispatchEvent ( document , endEvent ) ;
19171917 fixture . detectChanges ( ) ;
19181918 } ) . not . toThrow ( ) ;
1919+ } ) ) ;
1920+
1921+ it ( 'should not move the item if the group is disabled' , fakeAsync ( ( ) => {
1922+ const fixture = createComponent ( ConnectedDropZonesViaGroupDirective ) ;
1923+ fixture . detectChanges ( ) ;
1924+ const dragItems = fixture . componentInstance . groupedDragItems [ 0 ] ;
1925+
1926+ fixture . componentInstance . groupDisabled = true ;
1927+ fixture . detectChanges ( ) ;
1928+
1929+ expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
1930+ . toEqual ( [ 'Zero' , 'One' , 'Two' , 'Three' ] ) ;
1931+
1932+ const firstItem = dragItems [ 0 ] ;
1933+ const thirdItemRect = dragItems [ 2 ] . element . nativeElement . getBoundingClientRect ( ) ;
19191934
1935+ dragElementViaMouse ( fixture , firstItem . element . nativeElement ,
1936+ thirdItemRect . right + 1 , thirdItemRect . top + 1 ) ;
1937+ flush ( ) ;
1938+ fixture . detectChanges ( ) ;
1939+
1940+ expect ( fixture . componentInstance . droppedSpy ) . not . toHaveBeenCalled ( ) ;
1941+
1942+ expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
1943+ . toEqual ( [ 'Zero' , 'One' , 'Two' , 'Three' ] ) ;
19201944 } ) ) ;
19211945
19221946 } ) ;
@@ -2742,7 +2766,7 @@ class ConnectedDropZones implements AfterViewInit {
27422766 }
27432767 ` ] ,
27442768 template : `
2745- <div cdkDropListGroup>
2769+ <div cdkDropListGroup [cdkDropListGroupDisabled]="groupDisabled" >
27462770 <div
27472771 cdkDropList
27482772 [cdkDropListData]="todo"
@@ -2759,7 +2783,9 @@ class ConnectedDropZones implements AfterViewInit {
27592783 </div>
27602784 `
27612785} )
2762- class ConnectedDropZonesViaGroupDirective extends ConnectedDropZones { }
2786+ class ConnectedDropZonesViaGroupDirective extends ConnectedDropZones {
2787+ groupDisabled = false ;
2788+ }
27632789
27642790
27652791@Component ( {
0 commit comments