angular / angular/components

bug(cdkDrag): Can't reorder edge items with different size and boundary

Abierto
#27,801 4 comentarios 3 reacciones 0 asignados Ver en GitHub
area: cdk/drag-drop P3
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

I'm implementing draggable horizontal list, each item may has different width (depending on content). In case if first item is shorter than second and I want swop them and I capture second item closer to right edge it's impossible to set second item as first.
Note: cdkDrag constrained by X axis and has boundary
`cdkDragLockAxis="x" [cdkDragBoundary]="dropContainer"`

### Reproduction

StackBlitz link: https://stackblitz.com/edit/roitsa?file=src%2Fexample%2Fcdk-drag-drop-horizontal-sorting-example.ts
Steps to reproduce:
1. Capture "Bronze age" closer to right side (red area in the example)
2. Try to make it first in the list (swop with "Iron")

I was trying to make workaround with `cdkDragConstrainPosition` but without success as with this function behaviour changes, item reorders immediately if I drag left. Seems weird or I do something wrong
Example with `cdkDragConstrainPosition` : https://stackblitz.com/edit/roitsa-6kbo4x?file=src%2Fexample%2Fcdk-drag-drop-horizontal-sorting-example.html

### Expected Behavior

Ability to reorder edge items constrained by cdkDragBoundary

### Actual Behavior

Can't reorder edge items

### Environment

- Angular: v16
- CDK/Material:
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con las reproducciones de StackBlitz enlazadas, especialmente cdk-drag-drop-horizontal-sorting-example.ts y su HTML, y reproduce el caso de una lista horizontal con cdkDragLockAxis="x" y cdkDragBoundary. Traza cómo el arrastre restringido por los límites afecta a la ordenación cuando los elementos de los extremos tienen anchos diferentes; el trabajo estará terminado cuando el elemento Bronze age pueda reordenarse delante de Iron desde cualquiera de las dos posiciones iniciales.

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
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.