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-labelledby
applied that points to the tree's heading element. -
role="treeitem"
is placed on the treeli
elements -
aria-level
is applied totreeitem
elements to indicate their nesting depth -
aria-expanded
is applied totreeitem
elements that have child nodes. It is set totrue
orfalse
-
aria-selected="true"
is applied totreeitem
elements that are selected -
tabindex="0"
is applied to thetreeitem
that is in focus. All otherstreeitem
elements receivetabindex="-1"
-
role="group"
is applied to child tree node (branch) containerul
s
Interaction
- Only a single action per tree item
- Only 1 focusable item per tree
Navigation
- Clicking on a tree item selects it.
-
Up
anddown
arrow keys move:focus
andaria-selected
. If a node is expanded, the:focus
will move between levels of the tree to the neighbor. Previous selections are cleared. -
Right
arrow key will expand a collapsed node -
Left
arrow key will move:focus
andaria-selected
to the parent on an end child node, and will collapse the node if on a parent node and toggle thearia-expanded
tofalse
.
- David Wallace