feat(CdkDropList): Allow to connect to lists sharing the same ID
- Dominant language
- TypeScript
- Stars
- 25k
- Forks
- 6.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 91
Description
### Feature Description
Currently there seem to be no simple way to connect various drop lists in various components, unless they have a `cdkDropListGroup` on top of them, or a defined list of ids, which is not achievable in many cases.
Hence we could imagine that the `connectedTo` input could be used to connect several lists, depending on a single `id` parameter (or maybe some `groupName` ?), like :
```
// In some place in the code
...
// In a completely different place
...
// In another completely different place
```
Also the Input `connectedTo` already supports an ID as `string` but gets only a single element, as it can be seen in the code :
```
const siblings = coerceArray(this.connectedTo).map(drop => {
if (typeof drop === 'string') {
const correspondingDropList = CdkDropList._dropLists.find(list => list.id === drop); <-- Here
if (!correspondingDropList && (typeof ngDevMode === 'undefined' || ngDevMode)) {
console.warn(`CdkDropList could not find connected drop list with id "${drop}"`);
}
return correspondingDropList!;
}
return drop;
});
```
Hence replacing `.find(list => list.id === drop)` by a `.filter(list => list.id === drop)` pipe will allow to register as siblings all the lists that have this ID, so it may not be a big deal technically (in first approximation).
### Use Case
I've got a dataviz interface where datasets could be drag n' dropped in various containers (columns, graphs, segments, etc), but not knowing the number of them and not being able to get them under a single group.
Contributor guide
Research direction
Start at the CdkDropList connectedTo handling shown in the issue, especially the lookup of lists by id. Trace how connected drop lists are registered and identify existing coverage for connectedTo IDs. Done means the intended behavior for multiple lists sharing an ID is agreed, implemented without breaking single-ID connections, and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100