Skip to content

MatTree does not update items when using trackBy #18639

Closed
@matthiaswelz

Description

@matthiaswelz

When using trackBy, CdkTree / MatTree does not update items which share the same identity (as returned by trackBy), but are actually different obejcts (with property changes).
This behavior differs from the behavior shown by ngFor in combination with trackBy.

Reproduction

StackBlitz: https://stackblitz.com/edit/angular-cfph4s

Steps to reproduce:

  1. Click the button

Expected Behavior

The tree gets updated as the list created by ngFor does.

Actual Behavior

The tree does not change, only the list generated by ngFor.

Environment

  • Angular: 9.0.1
  • CDK/Material: 9.1.0
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/treearea: material/tree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions