Skip to content

Commit 746b110

Browse files
committed
refactor(cdk/drag-drop): use ID generator
Switches to using the ID generator service to create unique IDs.
1 parent dc03cda commit 746b110

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/cdk/drag-drop/directives/drop-list.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
inject,
2020
} from '@angular/core';
2121
import {Directionality} from '@angular/cdk/bidi';
22+
import {_IdGenerator} from '@angular/cdk/a11y';
2223
import {ScrollDispatcher} from '@angular/cdk/scrolling';
2324
import {CDK_DROP_LIST, CdkDrag} from './drag';
2425
import {CdkDragDrop, CdkDragEnter, CdkDragExit, CdkDragSortEvent} from '../drag-events';
@@ -31,9 +32,6 @@ import {merge, Subject} from 'rxjs';
3132
import {startWith, takeUntil} from 'rxjs/operators';
3233
import {assertElementNode} from './assertions';
3334

34-
/** Counter used to generate unique ids for drop zones. */
35-
let _uniqueIdCounter = 0;
36-
3735
/** Container that wraps a set of draggable items. */
3836
@Directive({
3937
selector: '[cdkDropList], cdk-drop-list',
@@ -91,7 +89,7 @@ export class CdkDropList<T = any> implements OnDestroy {
9189
* Unique ID for the drop zone. Can be used as a reference
9290
* in the `connectedTo` of another `CdkDropList`.
9391
*/
94-
@Input() id: string = `cdk-drop-list-${_uniqueIdCounter++}`;
92+
@Input() id: string = inject(_IdGenerator).getId('cdk-drop-list-');
9593

9694
/** Locks the position of the draggable elements inside the container along the specified axis. */
9795
@Input('cdkDropListLockAxis') lockAxis: DragAxis;

0 commit comments

Comments
 (0)