Tree
DraftA tree is visualization of a structure hierarchy. A branch can be expanded or collapsed.
About trees
A tree is composed of three core elements, a treeview, a tree and a treeitem. The treeview, .qw-treeview, is the container for the tree, and is the class that our JavaScript targets. The tree, the outermost ul will receive the class .qw-tree. This element wraps the primary level of branches and leaves. Branches have addtional child branches and leaves.
Markup
-
role="tree"is placed on the rootul -
role="tree"element hasaria-labelledbyapplied that points to the tree's heading element. -
role="treeitem"is placed on the treelielements -
aria-levelis applied totreeitemelements to indicate their nesting depth -
aria-expandedis applied totreeitemelements that have child nodes. It is set totrueorfalse -
aria-selected="true"is applied totreeitemelements that are selected -
tabindex="0"is applied to thetreeitemthat is in focus. All otherstreeitemelements receivetabindex="-1" -
role="group"is applied to child tree node (branch) containeruls
Interaction
- Only a single action per tree item
- Only 1 focusable item per tree
Navigation
- Clicking on a tree item selects it.
-
Upanddownarrow keys move:focusandaria-selected. If a node is expanded, the:focuswill move between levels of the tree to the neighbor. Previous selections are cleared. -
Rightarrow key will expand a collapsed node -
Leftarrow key will move:focusandaria-selectedto the parent on an end child node, and will collapse the node if on a parent node and toggle thearia-expandedtofalse.
- David Wallace