@@ -28,7 +28,7 @@ import {_supportsShadowDom} from '@angular/cdk/platform';
28
28
import { of as observableOf } from 'rxjs' ;
29
29
30
30
import { DragDropModule } from '../drag-drop-module' ;
31
- import { CdkDragDrop , CdkDragEnter } from '../drag-events' ;
31
+ import { CdkDragDrop , CdkDragEnter , CdkDragStart } from '../drag-events' ;
32
32
import { Point , DragRef } from '../drag-ref' ;
33
33
import { extendStyles } from '../drag-styling' ;
34
34
import { moveItemInArray } from '../drag-utils' ;
@@ -4022,6 +4022,20 @@ describe('CdkDrag', () => {
4022
4022
expect ( fixture . componentInstance . droppedSpy ) . toHaveBeenCalledTimes ( 1 ) ;
4023
4023
} ) ) ;
4024
4024
4025
+ it ( 'should make the placeholder available in the start event' , fakeAsync ( ( ) => {
4026
+ const fixture = createComponent ( DraggableInDropZone ) ;
4027
+ fixture . detectChanges ( ) ;
4028
+ const item = fixture . componentInstance . dragItems . toArray ( ) [ 1 ] . element . nativeElement ;
4029
+ let placeholder : HTMLElement | undefined ;
4030
+
4031
+ fixture . componentInstance . startedSpy . and . callFake ( ( event : CdkDragStart ) => {
4032
+ placeholder = event . source . getPlaceholderElement ( ) ;
4033
+ } ) ;
4034
+
4035
+ startDraggingViaMouse ( fixture , item ) ;
4036
+ expect ( placeholder ) . toBeTruthy ( ) ;
4037
+ } ) ) ;
4038
+
4025
4039
} ) ;
4026
4040
4027
4041
describe ( 'in a connected drop container' , ( ) => {
@@ -5409,6 +5423,7 @@ const DROP_ZONE_FIXTURE_TEMPLATE = `
5409
5423
[cdkDragPreviewClass]="previewClass"
5410
5424
[style.height.px]="item.height"
5411
5425
[style.margin-bottom.px]="item.margin"
5426
+ (cdkDragStarted)="startedSpy($event)"
5412
5427
style="width: 100%; background: red;">{{item.value}}</div>
5413
5428
</div>
5414
5429
` ;
@@ -5430,6 +5445,7 @@ class DraggableInDropZone {
5430
5445
droppedSpy = jasmine . createSpy ( 'dropped spy' ) . and . callFake ( ( event : CdkDragDrop < string [ ] > ) => {
5431
5446
moveItemInArray ( this . items , event . previousIndex , event . currentIndex ) ;
5432
5447
} ) ;
5448
+ startedSpy = jasmine . createSpy ( 'started spy' ) ;
5433
5449
}
5434
5450
5435
5451
@Component ( {
0 commit comments