angular / angular/components

feat(CdkDropList): Allow to connect to lists sharing the same ID

Aperta
#27,493 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
area: cdk/drag-drop feature P4
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.