angular / angular/components

bug(drag-drop): Slot content not visible when we start dragging an element

未关闭
#27,872 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: cdk/drag-drop P4
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Hi,

Background:
I am creating a reusable dynamic list component which also has the ability to drag and drop items in a list.
This component uses **slots** to dynamically project content from the consumer component.

Problem:
The component renders correctly.
But when I start dragging an item, the content in the slot is not visible.

Does anyone know how to solve this issue or any workaround for this?

@angular/cdk
@angular/cdk/drag-drop

Thanks!

### Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-jbsaba?file=src%2Fmain.ts
Steps to reproduce:
1. Click on "Item 1 in slot" and start dragging it.
2. Notice that the text "Item 1 in slot" is not visible while you are dragging the item.

### Expected Behavior

Any content in a slot element should be visible while dragging the element.

### Actual Behavior

Content in the slot is not visible while you are dragging the item.

### Environment

- Angular: 16.2.7
- CDK/Material: 16.2.6
- Browser(s): Chrome
- Operating System: macOS

### REASON -
I am still debugging but found the reason behind this problem.
As per documentation,
"When a cdkDrag element is picked up, it will create a preview element visible while dragging."
This causes another slot element to be created with the same name which is why we don't see its content.

Still trying to find a solution.

贡献指南

打开贡献指南

调研方向

打开链接的 StackBlitz 复现,并从 src/main.ts 开始。拖动“Item 1 in slot”,确认投影的 slot 内容在拖动预览中缺失。完成的标准是:拖动时 slot 文本仍保持可见,并且复现步骤仍然通过。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。