design-system-react icon indicating copy to clipboard operation
design-system-react copied to clipboard

Add Tree component. (54)

Open arunjeetsingh opened this issue 10 years ago • 19 comments

Acceptance criteria:

  1. Build tests for a tree component that implements the SLDS pattern
  2. Build the tree component
  3. Add documentation https://github.com/salesforce-ux/design-system-react-site/issues/33

Future tasks: 4. Add a search / filter #317 5. Add the highlighting component when ready #251

arunjeetsingh avatar Apr 18 '16 18:04 arunjeetsingh

Has anyone talked with Kyle Heldman's team about needing this for Setup?

Kyle's team also needs the component for Installed Packages within Setup. Development for Installed Packages has already started.

kwilloughby avatar May 24 '16 21:05 kwilloughby

@pixelprodotco

kwilloughby avatar May 25 '16 15:05 kwilloughby

SLDS for React tree prop API:

collection: React.PropTypes.oneOfType([
    React.PropTypes.array,
    React.PropTypes.object
]).isRequired,

autoOpen: React.PropTypes.bool,
autoOpenLimit: React.PropTypes.number,
heading: React.PropTypes.string,
id: React.PropTypes.string,
disabled: React.PropTypes.bool,
folderSelect: React.PropTypes.bool,
multiSelect: React.PropTypes.bool,
onChanged: React.PropTypes.func,
onClosed: React.PropTypes.func,
onOpened: React.PropTypes.func,
open: React.PropTypes.any,
selection: React.PropTypes.any

Selection, multi-select, folderSelect, autoOpen seem like app state engine tasks to me, now that jQuery isn't included. You'd just be manipulating the nodes tree with a new variable. We can enable the onClick for folders if we want to have a folders, but it seems like a better idea to just not have the selection changes in the onClick event.

interactivellama avatar Jun 13 '16 18:06 interactivellama

  • Does MVP need loading state for tree #319
  • SLDS for React has a loading state (maybe part of getNodes(node) and a prop like "load")
  • Do we need direction from SLDS? There is no documentation on website.

interactivellama avatar Jun 13 '16 18:06 interactivellama

Do not implement autoOpen. Make an additional snippet that scans nodes datasource and creates expanded prop to be passed in.

interactivellama avatar Jun 13 '16 20:06 interactivellama

Result of tree discussion @tweettypography / @interactivellama

Do not support: autoOpen autoOpenLimit disabled: do not implement disabled tree or disabled items, needs SLDS CSS folderSelect multiSelect onClosed onOpened

Do support:

  • [x] open -> expanded - implement expanded via expanded prop and not node datasource
  • [x] selection - - implement selection via selection prop and not node datasource (may later use datasource, selected key
  • [x] getNodes - w/ Promise
  • [x] onClick - would pass back all item keys from nodes data + current selection, and handler should handle folder or multiSelect if needed

If crutch is needed for features not supported, it will be provided in sample snippet or in extended component.

  • [x] implement child component arrays with shortid id

Update: getNodes as a promise has been removed.

interactivellama avatar Jun 14 '16 02:06 interactivellama

Current state of Tree: https://github.com/interactivellama/design-system-react/tree/tree-component Not anywhere near a11y functional, nor complete testing, but just raising for transparency.

interactivellama avatar Jun 17 '16 16:06 interactivellama

a11y links for reference:

  • http://www.oaa-accessibility.org/examplep/treeview1/
  • http://w3c.github.io/aria/practices/aria-practices.html#TreeView
  • https://www.w3.org/WAI/GL/wiki/Using_aria-activedescendant_to_allow_changes_in_focus_within_widgets_to_be_communicated_to_Assistive_Technology https://www.marcozehe.de/2012/02/06/if-you-use-the-wai-aria-role-application-please-do-so-wisely/

interactivellama avatar Jun 17 '16 19:06 interactivellama

MobileConnect squad has a need for this control as well. I'd be glad to help with getting this tested.

kjaenicke avatar Aug 03 '16 14:08 kjaenicke

The need for infinite scroll/lazy load recently surfaced as a need and dependency for Kyle Heldman’s team.

@jamin-hall

kwilloughby avatar Aug 03 '16 21:08 kwilloughby

How does infinite scroll work in a tree?

Are their 1000 branches and you only want to load 100 and then load the rest 10 at time?

interactivellama avatar Aug 04 '16 00:08 interactivellama

@interactivellama One option: load each top level node up to X amount based on initial render performance (100?). As the node is expanded, render its children (either from existing data or via async call). Infinite scroll would be limited to just the top level nodes at that point.

I'm working on an alternative approach to how the tree is rendering at the moment. The version that existed when slds-for-react had a tree component has performance issues once the node count gets in the hundreds and above (thats including child nodes that may or may not be visible).

pixelprodev avatar Aug 04 '16 02:08 pixelprodev

I'm in the process of removing promises as an option for the tree nodes and moving forward with a loading prop that will put the tree into a loading UI state until the app provide the new nodes.

interactivellama avatar Aug 11 '16 15:08 interactivellama

Without promises as an option there would be no way to get children (from an async source) on expanding of a node, correct? Would the expectation be that something outside of the tree is building a static data source to pass in? Or am I missing something?

tweettypography avatar Aug 11 '16 15:08 tweettypography

My question is why do we want a promise on the tree and not anywhere else? Do we have precedence for promises with our data props somewhere else?

interactivellama avatar Aug 11 '16 16:08 interactivellama

The original need came from jQuery compatibility and backwards-compatibility with FuelUX, I believe. Neither of those are issues any longer, and it certainly does feel more react-like to simply throw an event and let the application take care of feeding in the new data. I could imagine that for very large, complex trees there might be some benefit to receiving the data back at the node level when it's ready so that you don't have to re-render the entire tree and add it back to the DOM, but I'm not sure that's even a relevant argument and would require some testing.

tweettypography avatar Aug 11 '16 16:08 tweettypography

I'd be curious what solutions all of the other treeviews have come up with: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=react%20treeview

tweettypography avatar Aug 11 '16 16:08 tweettypography

IMHO, the path forward for infinite scroll is to pass scroll position of the ul element to the app and if it wants to load more nodes it can.

I've added an onScroll event that returns the percentage of the scroll.

interactivellama avatar Aug 15 '16 19:08 interactivellama

Possible loading pattern:

2016-08-19 21 48 48

interactivellama avatar Aug 20 '16 01:08 interactivellama