angular / angular/components

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

Abierto
#27,872 4 comentarios 0 reacciones 0 asignados Ver en GitHub
area: cdk/drag-drop P4
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Abre la reproducción vinculada de StackBlitz y empieza con src/main.ts. Arrastra “Item 1 in slot” para confirmar que el contenido proyectado del slot falta en la vista previa del arrastre. Se considera terminado cuando el texto del slot permanece visible mientras se arrastra y los pasos de reproducción siguen pasando.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.