Skip to content

Commit

Permalink
fix(cdk/drag-drop): add generic parameter for item type in CdkDragDrop (
Browse files Browse the repository at this point in the history
#23209)

Fixes that the `CdkDragDrop` event didn't have a way of typing the item.

Fixes #23208.
  • Loading branch information
crisbeto authored Aug 6, 2021
1 parent a4ae3b8 commit c03d8ac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/cdk/drag-drop/drag-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ export interface CdkDragExit<T = any, I = T> {


/** Event emitted when the user drops a draggable item inside a drop container. */
export interface CdkDragDrop<T, O = T> {
export interface CdkDragDrop<T, O = T, I = any> {
/** Index of the item when it was picked up. */
previousIndex: number;
/** Current index of the item. */
currentIndex: number;
/** Item that is being dropped. */
item: CdkDrag;
item: CdkDrag<I>;
/** Container in which the item was dropped. */
container: CdkDropList<T>;
/** Container from which the item was picked up. Can be the same as the `container`. */
Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/cdk/drag-drop.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
}

// @public
export interface CdkDragDrop<T, O = T> {
export interface CdkDragDrop<T, O = T, I = any> {
container: CdkDropList<T>;
currentIndex: number;
distance: {
Expand All @@ -115,7 +115,7 @@ export interface CdkDragDrop<T, O = T> {
y: number;
};
isPointerOverContainer: boolean;
item: CdkDrag;
item: CdkDrag<I>;
previousContainer: CdkDropList<O>;
previousIndex: number;
}
Expand Down

0 comments on commit c03d8ac

Please sign in to comment.