angular / angular/components

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

Aperta
#27,801 4 commenti 3 reazioni 0 assegnatari Vedi su GitHub
area: cdk/drag-drop P3
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con le riproduzioni StackBlitz collegate, in particolare cdk-drag-drop-horizontal-sorting-example.ts e il relativo HTML, e riproduci il caso di un elenco orizzontale con cdkDragLockAxis="x" e cdkDragBoundary. Traccia in che modo il trascinamento vincolato dai limiti influisce sull'ordinamento quando gli elementi ai bordi hanno larghezze diverse; il lavoro è completo quando l'elemento Bronze age può essere riordinato prima di Iron da entrambe le posizioni di cattura.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
frontend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.