Angular-tree-component: Checking node with not-yet-loaded children causes an exception

Created on 20 Dec 2017  路  6Comments  路  Source: CirclonGroup/angular-tree-component

Hi there,

I'm having some issues combining lazy loading with checkboxes. Checking a node with hasChildren: true when the children are not loaded yet causes an exception. See plunkr:
https://plnkr.co/edit/wigPSzzk3R0XM9RE173D?p=preview

Steps to reproduce:

  1. Check Root2

SecondChild has one async loaded child and is not checked after expanding.
After all the async children are loaded the issue disappears.

Is there a way to work around this or is this a bug?

Stack trace from plunkr:

ERROR TypeError: Cannot read property 'forEach' of undefined
    at e.setIsSelected (VM630 [email protected]:1)
    at eval (VM630 [email protected]:1)
    at Array.forEach (<anonymous>)
    at ObservableArray.eval (VM672 mobx@^3:697)
    at e.setIsSelected (VM630 [email protected]:1)
    at e.toggleSelected (VM630 [email protected]:1)
    at TOGGLE_SELECTED (VM630 [email protected]:1)
    at e.mouseAction (VM630 [email protected]:1)
    at Object.eval [as handleEvent] (VM674 e.ngfactory.js:13)
    at handleEvent (VM627 core.umd.js:13620)

Thanks for the work on the tree component and looking forward to hearing from you.

Most helpful comment

Here is a fix that I have issued in a local branch. I attempted to push this up to the repo in a new branch but access was denied

In tree-node.model.ts / setIsSelected

  setIsSelected(value) {
    if (this.isLeaf || !this.children) {
      this.treeModel.setSelectedNode(this, value);
    } else {
      this.children.forEach((child) => child.setIsSelected(value));
    }

    return this;
  }

All 6 comments

+1

+1. Has there been any updates on this issue?

Here is a fix that I have issued in a local branch. I attempted to push this up to the repo in a new branch but access was denied

In tree-node.model.ts / setIsSelected

  setIsSelected(value) {
    if (this.isLeaf || !this.children) {
      this.treeModel.setSelectedNode(this, value);
    } else {
      this.children.forEach((child) => child.setIsSelected(value));
    }

    return this;
  }

+1

@jlewisitv Could you success to commit it?
@ilyagelman could you please consider it?

I have faced to it too. I don't know there is other solutions or not! but I think that it should be right.

I could not create a new branch and push I was unauthorised and therefor could not create a pull request

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gillardo picture Gillardo  路  5Comments

BrkCoder picture BrkCoder  路  4Comments

anoop-chauhan picture anoop-chauhan  路  3Comments

hipresario picture hipresario  路  4Comments

thohoh picture thohoh  路  5Comments