bug(cdkDrag): Can't reorder edge items with different size and boundary
- Vorherrschende Sprache
- TypeScript
- Sterne
- 25k
- Forks
- 6.8k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
### 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
Beitragsleitfaden
Rechercherichtung
Beginne mit den verknüpften StackBlitz-Reproduktionen, insbesondere cdk-drag-drop-horizontal-sorting-example.ts und seinem HTML, und reproduziere den Fall einer horizontalen Liste mit cdkDragLockAxis="x" und cdkDragBoundary. Verfolge, wie sich das durch die Begrenzung eingeschränkte Ziehen auf die Sortierung auswirkt, wenn die Elemente an den Rändern unterschiedliche Breiten haben; fertig ist die Aufgabe, wenn das Bronze age-Element aus beiden Ausgangspositionen vor Iron neu angeordnet werden kann.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- angular, typescript
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100