angular / angular/components

feat(cdk/drag-drop): Allow dynamic drop lists creation while dragging an item

Ouverte
#28,958 1 commentaire 4 réactions 0 personnes assignées Voir sur GitHub
area: cdk/drag-drop feature P4
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

### Feature Description

I have noticed that if I try to create a drop list dynamically while I am dragging an item, the drop list is created graphically but it is not possible to drop the item I am dragging into that drop list. This seems to happen because the "_siblings" are created at drag initiation and do not notice if a row is created at runtime. It start working after a few drop list exit or enter but not if you directly go to that drop list.

Would it be possible to have this feature?
Or if it is already possible could you tell me how to do it?
For the moment I solved it by adding this method to my code, but it seems to me a very dirty solution.

```typescript
private refreshDropLists() {
// do it only if the component rows and the library rows are not sync
if (this.dropLists.toArray().length === this.configuration.length) {
// loop over the droplists
this.dropLists.toArray().forEach((dropList) => {
// force to recalculate the row positions
// @ts-ignore
dropList._dropListRef._cacheParentPositions();
// force the link between each row except for the row itself
dropList._dropListRef.connectedTo(
this.dropLists
.toArray()
.filter((dropList2) => dropList.id !== dropList2.id)
.map((droplist2) => droplist2._dropListRef)
);
});
}
}
```

An example can be viewed at the following link: https://stackblitz.com/edit/stackblitz-starters-7xvrf3?file=src%2Fapp%2Fapp.component.ts

If you want to make it work where to uncomment line 30 and 31 of the file "app.component.ts"

### Use Case

A useful use case would be, as with the linked stackblitz, creating a new droplists from the element I am dragging.
So if I have as in my case a structure of rows and columns, I want to be able to drag my column to a new row that doesn't exist.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par l’exemple StackBlitz lié, en particulier src/app/app.component.ts, et reproduisez la création d’une drop list pendant le glisser. Lisez la gestion de CDK drag-drop pour les listes sœurs et vérifiez qu’une liste nouvellement créée accepte un drop direct sans le workaround ; ajoutez ou mettez à jour des tests ciblés si le point d’entrée de test pertinent est identifié.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.