Skip to content

Dynamic nested tree - children data loaded twice #18682

Open
@kctang

Description

@kctang

I hit this issue when trying to implement a nested tree using Angular Material where nodes can dynamically load children nodes (when user expands the tree control).

Reproduction

See a demo of the issue here.

I asked as a question on SO here.

Expected Behavior

In the demo, nodes with nested children returns an observable of nodes[]. I expect this to be called once (i.e. when user expands the node).

Actual Behavior

When user expands the node, the observable is called twice (i.e. loading data twice). However, end result 'seems to work' - just not ideal as it loads data twice.

Additional Comments

I expect getChildren function passed to NestedTreeControl to be called once per node but i think it can be called twice.

Based on my local testing, if I remove <mat-nested-tree-node> (in green), then getChildren is called once per node. I think it has something to do with this but I do not understand the internals of this tree component enough to say more.

Hope someone can help or point me to the right direction. Cheers!

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/treeneeds investigationA member of the team needs to do further investigation to determine the root cause

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions