angular / angular/components

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

Đang mở
#28,958 1 bình luận 4 reaction 0 người được giao Xem trên GitHub
area: cdk/drag-drop feature P4
Ngôn ngữ chính
TypeScript
Star
25k
Fork
6.8k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
91

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với ví dụ StackBlitz được liên kết, đặc biệt là src/app/app.component.ts, và tái hiện việc tạo một drop list trong khi kéo. Đọc phần xử lý CDK drag-drop cho các danh sách cùng cấp và xác minh rằng một danh sách mới được tạo chấp nhận thao tác drop trực tiếp mà không cần workaround; thêm hoặc cập nhật các bài kiểm thử tập trung nếu xác định được điểm vào kiểm thử liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
frontend
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.