Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cdk/drag-drop/directives/drag-placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ export const CDK_DRAG_PLACEHOLDER = new InjectionToken<CdkDragPlaceholder>('CdkD
providers: [{provide: CDK_DRAG_PLACEHOLDER, useExisting: CdkDragPlaceholder}],
})
export class CdkDragPlaceholder<T = any> implements OnDestroy {
private _drag = inject(CDK_DRAG_PARENT);
private _drag = inject(CDK_DRAG_PARENT, {optional: true});

/** Context data to be added to the placeholder template instance. */
@Input() data: T;

constructor(public templateRef: TemplateRef<T>) {
this._drag._setPlaceholderTemplate(this);
this._drag?._setPlaceholderTemplate(this);
}

ngOnDestroy(): void {
this._drag._resetPlaceholderTemplate(this);
this._drag?._resetPlaceholderTemplate(this);
}
}
6 changes: 3 additions & 3 deletions src/cdk/drag-drop/directives/drag-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const CDK_DRAG_PREVIEW = new InjectionToken<CdkDragPreview>('CdkDragPrevi
providers: [{provide: CDK_DRAG_PREVIEW, useExisting: CdkDragPreview}],
})
export class CdkDragPreview<T = any> implements OnDestroy {
private _drag = inject(CDK_DRAG_PARENT);
private _drag = inject(CDK_DRAG_PARENT, {optional: true});

/** Context data to be added to the preview template instance. */
@Input() data: T;
Expand All @@ -43,10 +43,10 @@ export class CdkDragPreview<T = any> implements OnDestroy {
@Input({transform: booleanAttribute}) matchSize: boolean = false;

constructor(public templateRef: TemplateRef<T>) {
this._drag._setPreviewTemplate(this);
this._drag?._setPreviewTemplate(this);
}

ngOnDestroy(): void {
this._drag._resetPreviewTemplate(this);
this._drag?._resetPreviewTemplate(this);
}
}