angular / angular/components

bug(drag-drop): Failed to execute insertBefore on Node

Offen
#29,358 3 Kommentare 9 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area: cdk/drag-drop P4
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

When drag and drop is used and data refreshes in background this error can be thrown
```
ERROR DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
```

### Reproduction

StackBlitz link: https://stackblitz.com/edit/a9tq3w?file=src%2Fexample%2Fcdk-drag-drop-connected-sorting-example.html
Steps to reproduce:
1. Keep moving first element to the bottom (fast)

### Expected Behavior

Drag and drop should not cause `DOMException`

### Actual Behavior

https://github.com/angular/components/assets/21180501/9e1cee2a-d9e4-4460-a049-74821a66c827

https://github.com/angular/components/assets/21180501/ecaed375-0a32-404b-bbc2-860b58d1fe6d

```
ERROR DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
at EmulatedEncapsulationDomRenderer2.insertBefore (/vendor.js:84094:20)
at BaseAnimationRenderer.insertBefore (/vendor.js:17733:19)
at nativeInsertBefore (/vendor.js:50345:12)
at applyToElementOrContainer (/vendor.js:49879:7)
at applyNodes (/vendor.js:50571:9)
at applyView (/vendor.js:50578:3)
at addViewToDOM (/vendor.js:49947:3)
at addLViewToLContainer (/vendor.js:52300:7)
at LiveCollectionLContainerImpl.attach (/vendor.js:63156:5)
at LiveCollectionLContainerImpl.swap (/vendor.js:62667:12)
```

### Environment

Angular CLI: 18.0.2
Node: 18.20.3
Package Manager: yarn 1.22.19
OS: linux x64

Angular: 18.0.1
... animations, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router

Package Version
------------------------------------------------------------
@angular-devkit/architect 0.1800.2
@angular-devkit/build-angular 18.0.2
@angular-devkit/core 18.0.2
@angular-devkit/schematics 18.0.2
@angular/cdk 18.0.5
@angular/cli 18.0.2
@angular/material 18.0.5
@angular/material-experimental 18.0.5
@angular/material-moment-adapter 18.0.5
@schematics/angular 18.0.2
rxjs 7.4.0
typescript 5.4.5
zone.js 0.14.6

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der StackBlitz-Reproduktion unter src/example/cdk-drag-drop-connected-sorting-example.html und reproduziere den Fehler, indem du das erste Element wiederholt nach unten verschiebst, während die Daten aktualisiert werden. Verfolge die Drag-and-Drop-Aktualisierung durch die gemeldeten insertBefore- und LiveCollection-Stackframes; fertig ist die Änderung, wenn die Reproduktion keine DOMException mehr auslöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
38/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.