Nested tree does not correctly update
- Vorherrschende Sprache
- TypeScript
- Sterne
- 25k
- Forks
- 6.8k
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
#### Bug, feature request, or proposal:
Bug
#### What is the expected behavior?
Adding a node to the tree and firing a change event should update the tree
#### What is the current behavior?
The tree does not update
#### What are the steps to reproduce?
[StackBlitz link](https://stackblitz.com/edit/angular-kowmq5-pmrkej?file=app/tree-nested-overview-example.ts) line 123
Open the example, and within 10 seconds expand the Applications node.
The following code should add a node, and the node should be displayed:
```ts
database.dataChange.subscribe(data => {
this.nestedDataSource.data = data;
console.log(data); // <-- see screenshot below
});
console.log('Please expand the Applications node within 10 seconds');
setTimeout(() => {
const data = this.nestedDataSource.data;
for (let node of data) {
if (node.filename == "Applications") {
const newnode = new FileNode();
newnode.filename = "ghost";
newnode.type = "gs";
node.children.push(newnode);
console.log("Added component");
}
}
// force change
console.log("Forcing change");
database.dataChange.next(data); // <-- firing event here
}, 10000);
```
After ten seconds the console correctly logs the added component:

But the view does not update:

#### What is the use-case or motivation for changing an existing behavior?
I would expect the tree to mirror the underlying data model.
#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
It happens on chrome, with the latest version of the library.
#### Is there anything else we should know?
Sorry I could not make the example autoexpand (please see #13027 on why)
Beitragsleitfaden
Rechercherichtung
Beginnen Sie mit app/tree-nested-overview-example.ts in Zeile 123 und reproduzieren Sie das Problem, indem Sie Applications vor der verzögerten Aktualisierung erweitern. Verfolgen Sie, wie nestedDataSource.data und database.dataChange behandelt werden, nachdem der untergeordnete Knoten hinzugefügt wurde. Fertig ist die Arbeit, wenn die Ansicht den neuen Geisterknoten anzeigt, sobald das Änderungsereignis ausgelöst wird.
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
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100