private onItemKeyDown()

in src/draft-components/tree-actions/tree-actions.tsx [280:306]


  private onItemKeyDown(event: KeyboardEvent, item: TreeItem, itemID: string) {
    const isExpanded = this.expandedItems.get(item);
    const action = getTreeActionFromKey(event, item, isExpanded, itemID.length);

    switch (action) {
      case TreeActions.First:
      case TreeActions.Last:
      case TreeActions.Next:
      case TreeActions.Previous:
      case TreeActions.UpLevel:
        const newID = this.getUpdatedID(itemID, action);
        if (typeof newID === 'string') {
          this.onItemChange(newID);
          this.callFocus = true;
        }
        break;
      case TreeActions.Close:
        this.collapseChildren(item, itemID);
        break;
      case TreeActions.Open:
        this.expandChildren(item, itemID);
        break;
      case TreeActions.Select:
        item.onClick && item.onClick(item);
        break;
    }
  }