@@ -636,6 +636,22 @@ describe('CdkDrag', () => {
636636 expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
637637 } ) ) ;
638638
639+ it ( 'should be able to set an alternate drag root element for ng-container' , fakeAsync ( ( ) => {
640+ const fixture = createComponent ( DraggableNgContainerWithAlternateRoot ) ;
641+ fixture . detectChanges ( ) ;
642+
643+ const dragRoot = fixture . componentInstance . dragRoot . nativeElement ;
644+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
645+
646+ expect ( dragRoot . style . transform ) . toBeFalsy ( ) ;
647+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
648+
649+ dragElementViaMouse ( fixture , dragRoot , 50 , 100 ) ;
650+
651+ expect ( dragRoot . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
652+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
653+ } ) ) ;
654+
639655 it ( 'should preserve the initial transform if the root element changes' , fakeAsync ( ( ) => {
640656 const fixture = createComponent ( DraggableWithAlternateRoot ) ;
641657 fixture . detectChanges ( ) ;
@@ -7150,6 +7166,22 @@ class DraggableWithRadioInputsInDropZone {
71507166 ] ;
71517167}
71527168
7169+
7170+ @Component ( {
7171+ template : `
7172+ <div #dragRoot class="alternate-root" style="width: 200px; height: 200px; background: hotpink">
7173+ <ng-container cdkDrag cdkDragRootElement=".alternate-root" #dragElement>
7174+ <div style="width: 100px; height: 100px; background: red;"></div>
7175+ </ng-container>
7176+ </div>
7177+ `
7178+ } )
7179+ class DraggableNgContainerWithAlternateRoot {
7180+ @ViewChild ( 'dragElement' ) dragElement : ElementRef < HTMLElement > ;
7181+ @ViewChild ( 'dragRoot' ) dragRoot : ElementRef < HTMLElement > ;
7182+ @ViewChild ( CdkDrag ) dragInstance : CdkDrag ;
7183+ }
7184+
71537185/**
71547186 * Drags an element to a position on the page using the mouse.
71557187 * @param fixture Fixture on which to run change detection.
0 commit comments