CirclonGroup / angular-tree-component

A simple yet powerful tree component for Angular (>=2)
https://angular2-tree.readme.io/docs
MIT License
1.1k stars 492 forks source link

Tree is showing updates. Need to click on the screen to show. #901

Open lesianocmn opened 3 years ago

lesianocmn commented 3 years ago

Hello,

I have an issue with showing the tree.

Before after adding nodes you could see the information. Now I have to click on the screen to see the tree with the nodes. (if not it continues showing "loading")

I checked and If I add a setTimeout with anything there after change the tree, it is showing again.

    setTimeout(function () {
      let something = 0;
    }, 1400);

I'm missing something or do I have to change something?

Thanks for your help.

tobiasengelhardt commented 3 years ago

How are you adding the nodes? I tried it with the normal getChildren function and also with just resetting the nodes after the page loaded. Both work for me without clicking.

lesianocmn commented 3 years ago

Hello, Thanks for your comment. I'm also resetting the nodes and I'm using the getChildren function. I kind find out a solution using ChangeDetectionStrategy OnPush.

colorcube commented 3 years ago

I had the same problem. The tree showed after click only.

I tried several workarounds. This works for me:

  constructor(private ref: ChangeDetectorRef){}

  ngOnInit() {
    this.myService.getNodes().subscribe(nodes => {
      this.nodes = [...nodes];
      this.ref.detectChanges();
    });
  }

It worked before I migrated to angular v 12 and material. No idea if there's a connection

lesianocmn commented 3 years ago

Hi @colorcube ,

Yes, It's what I did.. I think it's the only solution by now..