angular / angular/components

bug(tree): Using cdk-tree with ArrayDataSource and Observable can cause expand functionality to fail under certain conditions.

Ouverte
#29,661 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
area: material/tree needs investigation P2
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

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

Using cdk-tree with ArrayDataSource and Observable, the expand functionality can fail under the following conditions:
1. The Observable emits more than one value asynchronously.
2. The emitted values are dynamically generated.
3. trackBy is not based on identity comparison.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/2ypkpy?file=src%2Fexample%2Fcdk-tree-flat-children-accessor-example.ts
Steps to reproduce:
Click the tree node toggler

### Expected Behavior

Child nodes expand normally.

### Actual Behavior

Child nodes fail to expand.

### Environment

```
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/

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

Angular: 18.2.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... localize, material, material-experimental
... material-moment-adapter, platform-browser
... platform-browser-dynamic, router

Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1802.1
@angular-devkit/build-angular 18.2.1
@angular-devkit/core 18.2.1
@angular-devkit/schematics 18.2.1
@angular/cli 18.2.1
@schematics/angular 18.2.1
rxjs 7.4.0
typescript 5.5.4
zone.js 0.14.10
```

- Browser(s): Edge 127.0.2651.105
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la reproduction StackBlitz liée, en particulier src/example/cdk-tree-flat-children-accessor-example.ts, et cliquez sur le bouton de bascule du nœud de l’arbre tout en observant les émissions asynchrones. Suivez le comportement de cdk-tree pour les valeurs générées dynamiquement avec un trackBy qui n’est pas basé sur l’identité ; le travail est terminé lorsque les nœuds enfants se développent normalement dans ces conditions.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
30/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.