Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(cdk-tree): CDK Tree can't be opened when trackBy function is used after update of datasource #30403

Open
1 task done
MeMeMax opened this issue Jan 28, 2025 · 1 comment
Labels
area: cdk/tree P2 The issue is important to a large percentage of users, with a workaround

Comments

@MeMeMax
Copy link

MeMeMax commented Jan 28, 2025

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

Angular 17 (here is the same example: https://stackblitz.com/edit/zmfrj6ks?file=src%2Fexample%2Fcdk-tree-nested-example.ts,src%2Fexample%2Fcdk-tree-nested-example.html with Angular 17)

Description

Hi, there is a bug in the Angular CDK Tree. When you update the data of the tree and a trackBy function is given to the tree, you can't interact with the tree anymore.

Reproduction

StackBlitz link: https://stackblitz.com/edit/fesfbplt?file=src%2Fexample%2Fcdk-tree-nested-children-accessor-example.html
Steps to reproduce:

  1. interact with the tree (not mandatory, but you see that it works)
  2. click on "changeTree" button
  3. try to open the tree again => this doesn't work

Expected Behavior

Tree should be updateable and interactive after an update. I would also expect that the open state is kept when only part of the tree is changed (in the example one subtree is removed, the other persists) and a trackby function is given.

Actual Behavior

Tree is closed and not interactive anymore.

Environment

  • Angular: 18/19
  • CDK/Material: 18/19
  • Browser(s): all
  • Operating System (e.g. Windows, macOS, Ubuntu): windows
@MeMeMax MeMeMax added the needs triage This issue needs to be triaged by the team label Jan 28, 2025
@wagnermaciel wagnermaciel added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: cdk/tree P2 The issue is important to a large percentage of users, with a workaround and removed needs triage This issue needs to be triaged by the team P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Jan 29, 2025
@wagnermaciel
Copy link
Contributor

wagnermaciel commented Jan 29, 2025

Potential duplicate of #11381

Edit: After investigating, it seems this is unrelated to #11381 and instead seems to be a weird interaction between trackBy and expansion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/tree P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

No branches or pull requests

2 participants