public componentDidUpdate()

in fuse-ui-fabric/tree/treeView.tsx [28:53]


  public componentDidUpdate(prevProps: TreeViewProps<T>, prevState: TreeViewState) {
    const prevData = prevProps.selectedData;
    const curData = this.props.selectedData;
    const needUpdateSelection = prevData !== curData ||
      ((this.props.selectedData || this.state.contextVisible) && !this.selected);

    if (needUpdateSelection) {
      // the selected tree node view got unmounted
      const selected = this.props.selectedData;
      // find the matching tree node view
      const treeNodes = this.iterateTreeNodeViews();
      let iter = treeNodes.next();

      while (!iter.done) {
        const c = iter.value;
        if (c.node === selected) {
          this.select(c);
          if (!selected.name) {
            this.selected.edit();
          }
          break;
        }
        iter = treeNodes.next();
      }
    }
  }