Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree widget #1214

Closed
xiaohulu opened this issue Mar 29, 2020 · 7 comments · Fixed by #1516
Closed

Tree widget #1214

xiaohulu opened this issue Mar 29, 2020 · 7 comments · Fixed by #1516
Assignees

Comments

@xiaohulu
Copy link
Contributor

xiaohulu commented Mar 29, 2020

Similar to

https://ant.design/components/tree/
https://github.com/react-component/tree/

@jellison
Copy link

jellison commented Apr 30, 2020

@xiaohulu We should decide on some requirements. Any one thing in particular that would be a deal-breaker if it were missing?

Features

Required

  • expand/collapse
  • checkable/selectable
  • dynamic loading (with resources)
  • disable-able
  • customizable icon

Nice to have

  • partial selection (requires tri-state checkbox widget)
    image

Examples

Themes

Material

image

Dojo

image

API

export interface TreeNode {
    title: string | RenderResult;
    icon?: IconType;
    children?: TreeNode[] | boolean;    // child nodes or `true` to indicate children should be loaded dynamically; `[]`, `undefined`, and `false` indicates leaf node 
    expanded?: boolean;    // node is initially expanded
    disabled?: boolean;    // disables this node when tree allows selection
}

export interface TreeProperties {
    nodes: TreeNode[];
    allowSelection?: 'single' | 'multiple';
    onLoad?(node: TreeNode): TreeNode[];    // dynamically load node children
    onExpand?(node: TreeNode): void;
    onCollapse?(node: TreeNode): void;
    onSelect?(node: TreeNode): void;
}

Simple example usage

<Tree nodes={nodes} onLoad={loadChildren} />

Upcoming Widget Variations

@xiaohulu
Copy link
Contributor Author

xiaohulu commented May 1, 2020

I'm not very sure. edit node (with resources?) maybe not part of tree feature, because of data driven.

  • add a node
  • remove a node and it's children
  • move node
  • update a node info

@jellison
Copy link

jellison commented May 1, 2020

That's all good stuff. I may recommend we move all the editing to a separate widget?

@xiaohulu
Copy link
Contributor Author

xiaohulu commented May 1, 2020

Maybe not.

@jellison jellison self-assigned this May 4, 2020
@jellison jellison mentioned this issue May 12, 2020
7 tasks
@tomdye
Copy link
Member

tomdye commented May 14, 2020

As discussed on a call / screenshare:

I think that for this POC we need to work on getting the tree to have an api similar the list and to accept a flat array of data (from a resource) to display the tree contents.

It would be beneficial if the tree could re-use the listItem / menuItem from the List widget as this would provide consistent styling / functionality .

We should support keyboard navigation.

Any content customisation should be provided via a child renderer, not via a property.

Data display concerns such as expanded / disabled should be moved outside of the data passed as they will not be a concern of the resource that provides the data. Should consider callbacks / expanded: string[] property containing id's or similar.

onExpand / collapse etc callbacks should probably return an id, not the entire item object.

@samends samends mentioned this issue Jul 21, 2020
7 tasks
@tomdye
Copy link
Member

tomdye commented Jul 22, 2020

In addition to the above notes, we should ensure

  • the tree widget works correctly with a remote resource.
  • the tree handles pagination as a resource may contain many results

An working example of a tree using a remote resource and fetching children via a query can be seen here: https://codesandbox.io/s/elegant-cartwright-sd0o0

@tomdye
Copy link
Member

tomdye commented Aug 27, 2020

From screenshare with @samends

  • Should a click / select also check a checkable tree list item
  • Should we add a property to disable parentSelection ?
  • How do we differentiate between expand and select?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants