private async confirmThenDelete()

in fuse-ui-fabric/tree/treeView.tsx [137:163]


  private async confirmThenDelete(): Promise<boolean> {
    if (this.props.readonly) {
      return Promise.resolve(false);
    }

    const x = createDeferred<boolean>();

    this.confirmDialog.setPrompt(`Deleting ${this.selected.node.name}?`);
    this.confirmDialog.setResponse(x);
    this.confirmDialog.setShowing(true);

    const f = await x.promise;
    this.confirmDialog.setShowing(false);
    if (f) {
      const parent = this.selected.parent;
      const next = this.findNext(this.selected) || this.findPrev(this.selected);
      await this.props.remove(this.selected.node);
      this.select(next);
      if (parent) {
        parent.forceUpdate();
      } else {
        this.forceUpdate();
      }
    }

    return f;
  }