File Directory Treeview Example Using Computed Properties
- The below example implements the
- Treeview Design Pattern
- to simulate a file selector.
- When users activate an item that represents a file name in the below tree, the name of the selected file appears in the read-only edit field next to the tree.
+ The following example implementation of the
+ Tree View Design Pattern
+ simulates a widget for selecting a file or folder from within a hierarchical file system for viewing in a file viewer.
+ In the My Documents
tree, each parent node represents a folder and each end node represents a file.
+ Activating a node selects the node and puts the name of the folder or file in the read-only edit field that represents the file viewer.
This example relies on the browser to compute values for aria-setsize
, aria-posinset
, and aria-level
.
- The ARIA 1.0 specification for these properties states that browsers can, but are not required to, compute their values.
+ The ARIA specification for these properties states that browsers can, but are not required to, compute their values.
So, some browser and assistive technology combinations may not compute or report correct position and level information if it is not explicitly declared.
If testing reveals gaps in support for these properties, override automatic computation by explicitly declaring their values as demonstrated in the example of a
File Directory Treeview using declared properties.
-
Similar examples include:
-Example
-Example
+
- File Viewer
+
+ My Documents
-
+ aria-expanded="false"
+ aria-selected="false">
Projects
- -
+
-
project-1.docx
- -
+
-
project-2.docx
-
+ aria-expanded="false"
+ aria-selected="false">
Project 3
- -
+
-
project-3A.docx
- -
+
-
project-3B.docx
- -
+
-
project-3C.docx
- -
+
-
project-4.docx
-
+ aria-expanded="false"
+ aria-selected="false">
Project 5
- -
+
-
project-5A.docx
- -
+
-
project-5B.docx
- -
+
-
project-5C.docx
- -
+
-
project-5D.docx
- -
+
-
project-5E.docx
- -
+
-
project-5F.docx
@@ -121,64 +126,68 @@
-
+ aria-expanded="false"
+ aria-selected="false">
Reports
-
+ aria-expanded="false"
+ aria-selected="false">
report-1
- -
+
-
report-1A.docx
- -
+
-
report-1B.docx
- -
+
-
report-1C.docx
-
+ aria-expanded="false"
+ aria-selected="false">
report-2
- -
+
-
report-2A.docx
- -
+
-
report-2B.docx
- -
+
-
report-2C.docx
- -
+
-
report-2D.docx
-
+ aria-expanded="false"
+ aria-selected="false">
report-3
- -
+
-
report-3A.docx
- -
+
-
report-3B.docx
- -
+
-
report-3C.docx
- -
+
-
report-3D.docx
@@ -186,64 +195,68 @@
-
+ aria-expanded="false"
+ aria-selected="false">
Letters
-
+ aria-expanded="false"
+ aria-selected="false">
letter-1
- -
+
-
letter-1A.docx
- -
+
-
letter-1B.docx
- -
+
-
letter-1C.docx
-
+ aria-expanded="false"
+ aria-selected="false">
letter-2
- -
+
-
letter-2A.docx
- -
+
-
letter-2B.docx
- -
+
-
letter-2C.docx
- -
+
-
letter-2D.docx
-
+ aria-expanded="false"
+ aria-selected="false">
letter-3
- -
+
-
letter-3A.docx
- -
+
-
letter-3B.docx
- -
+
-
letter-3C.docx
- -
+
-
letter-3D.docx
@@ -251,7 +264,7 @@
-
+
-
-
- +
- project-1.docx -
- +
- project-2.docx
-
+ aria-expanded="false"
+ aria-selected="false">
Project 3
-
-
- +
- project-3A.docx -
- +
- project-3B.docx -
- +
- project-3C.docx
- - +
- project-4.docx
-
+ aria-expanded="false"
+ aria-selected="false">
Project 5
-
-
- +
- project-5A.docx -
- +
- project-5B.docx -
- +
- project-5C.docx -
- +
- project-5D.docx -
- +
- project-5E.docx -
- +
- project-5F.docx
-
+ aria-expanded="false"
+ aria-selected="false">
report-1
-
-
- +
- report-1A.docx -
- +
- report-1B.docx -
- +
- report-1C.docx
-
+ aria-expanded="false"
+ aria-selected="false">
report-2
-
-
- +
- report-2A.docx -
- +
- report-2B.docx -
- +
- report-2C.docx -
- +
- report-2D.docx
-
+ aria-expanded="false"
+ aria-selected="false">
report-3
-
-
- +
- report-3A.docx -
- +
- report-3B.docx -
- +
- report-3C.docx -
- +
- report-3D.docx
-
+ aria-expanded="false"
+ aria-selected="false">
letter-1
-
-
- +
- letter-1A.docx -
- +
- letter-1B.docx -
- +
- letter-1C.docx
-
+ aria-expanded="false"
+ aria-selected="false">
letter-2
-
-
- +
- letter-2A.docx -
- +
- letter-2B.docx -
- +
- letter-2C.docx -
- +
- letter-2D.docx
-
+ aria-expanded="false"
+ aria-selected="false">
letter-3
-
-
- +
- letter-3A.docx -
- +
- letter-3B.docx -
- +
- letter-3C.docx -
- +
- letter-3D.docx
Accessibility Features
- To make the focus indicator easier to see, nodes in the tree have a custom focus and hover styling created using CSS focus and hover pseudo-classes.
+ To make the focus indicator easier to see, nodes in the tree have custom focus and hover styling created using CSS focus and hover pseudo-classes.
@@ -277,6 +290,11 @@ Terms Used to Describe Trees
Keyboard Support
+
+ Note that in this example, selection and focus are distinct; moving focus does not change which node is selected.
+ Because selection does not follow focus, keyboard and screen reader users can navigate and explore the tree without changing the content of the file viewer.
+ To learn more about this aspect of the design, read the guidance section about Deciding When to Make Selection Automatically Follow Focus.
+
@@ -285,14 +303,13 @@ Keyboard Support
-
- Enter
or Space
-
-
- - Performs the default action (e.g. onclick event) for the focused node.
- - In this example, the default action is to update the
File or Folder Selected
textbox.
-
-
+
+ Enter
+ Performs the default action, which is to select the node, causing the name of the node to appear in the File or Folder Selected
textbox.
+
+
+ Space
+ Performs the default action, which is to select the node, causing the name of the node to appear in the File or Folder Selected
textbox.
Down arrow
@@ -363,7 +380,7 @@ Keyboard Support
-
+
Accessibility Features
- To make the focus indicator easier to see, nodes in the tree have a custom focus and hover styling created using CSS focus and hover pseudo-classes. + To make the focus indicator easier to see, nodes in the tree have custom focus and hover styling created using CSS focus and hover pseudo-classes.
Keyboard Support
++ Note that in this example, selection and focus are distinct; moving focus does not change which node is selected. + Because selection does not follow focus, keyboard and screen reader users can navigate and explore the tree without changing the content of the file viewer. + To learn more about this aspect of the design, read the guidance section about Deciding When to Make Selection Automatically Follow Focus. +
Enter or Space |
-
-
|
+
---|---|
Enter | +Performs the default action, which is to select the node, causing the name of the node to appear in the File or Folder Selectedtextbox. |
+
Space | +Performs the default action, which is to select the node, causing the name of the node to appear in the File or Folder Selectedtextbox. |
Down arrow | @@ -363,7 +380,7 @@
Role, Property, State, and Tabindex Attributes
@@ -394,7 +411,7 @@Role, Property, State, and Tabindex Attributes
aria-labelledby="IDREF"
aria-labelledby="ID_REFERENCE"
ul
tree
.Role, Property, State, and Tabindex Attributes
tabindex="-1"
tabindex="-1"
li
-
@@ -417,12 +434,12 @@
Role, Property, State, and Tabindex Attributes
tabindex="0"
tabindex="0"
li
- Includes the
treeitem
element in the tab sequence.
- - Only one
treeitem
in thetree
hastabindex="0"
.
+ - Only one
treeitem
in thetree
hastabindex="0"
. - In this implementation, the first
treeitem
in thetree
is included in the tab sequence when the page loads. -
When the user moves focus in the
tree
, the element included in the tab sequence changes to the element with focus as described in the section on @@ -433,7 +450,7 @@Role, Property, State, and Tabindex Attributes
aria-expanded="false"
aria-expanded="false"
li
-
@@ -445,7 +462,7 @@
Role, Property, State, and Tabindex Attributes
aria-expanded="true"
aria-expanded="true"
li
-
@@ -455,6 +472,28 @@
Role, Property, State, and Tabindex Attributes
aria-selected="false"
li
-
+
- Applied to
treeitem
elements.
+ - Indicates the file or folder for the item is not currently selected. +
aria-selected="true"
li
-
+
- Applied to
treeitem
elements.
+ - Indicates the file or folder for the item is currently selected. +
group
Role, Property, State, and Tabindex Attributes
ul
element as a container of treeitem
elements that form a branch of the tree.treeitem
.aria-level
, aria-setsize
and aria-posinset
values for the nodes contained in the branch.Javascript and CSS Source Code
-
diff --git a/examples/treeview/treeview-1/treeview-1b.html b/examples/treeview/treeview-1/treeview-1b.html
index 4cc681a4fd..36e2b55fcc 100644
--- a/examples/treeview/treeview-1/treeview-1b.html
+++ b/examples/treeview/treeview-1/treeview-1b.html
@@ -12,6 +12,9 @@
+
+
@@ -28,15 +31,16 @@
File Directory Treeview Example Using Declared Properties
- The below example implements the - Treeview Design Pattern - to simulate a file selector. - When users activate an item that represents a file name in the below tree, the name of the selected file appears in the read-only edit field next to the tree. + The following example implementation of the + Tree View Design Pattern + simulates a widget for selecting a file or folder from within a hierarchical file system for viewing in a file viewer. + In the
My Documents
tree, each parent node represents a folder and each end node represents a file. + Activating a node selects the node and puts the name of the folder or file in the read-only edit field that represents the file viewer.The code in this example explicitly declares values for
+ The ARIA specification for these properties states that browsers can, but are not required to, compute these values. +aria-setsize
,aria-posinset
andaria-level
, which overrides browser computation of values for these properties. - The ARIA 1.0 specification for these properties states that browsers can, but are not required to, compute these values. -Similar examples include:
- File Directory Treeview using computed properties @@ -48,369 +52,414 @@
-
-
- Projects
-
-
-
-
- - project-1.docx - -
- - project-2.docx - -
-
-
- project-3
-
-
-
-
- - project-3A.docx - -
- - project-3B.docx - -
- - project-3C.docx - -
- - - project-4.docx - -
-
-
- project-5
-
-
-
-
- - project-5A.docx - -
- - project-5B.docx - -
- - project-5C.docx - -
- - project-5D.docx - -
- - project-5E.docx - -
- - project-5F.docx - -
-
- -
-
- Reports
-
-
-
-
-
-
- report-1
-
-
-
-
- - report-1A.docx - -
- - report-1B.docx - -
- - report-1C.docx - -
- -
-
- report-2
-
-
-
-
- - report-2A.docx - -
- - report-2B.docx - -
- - report-2C.docx - -
- - report-2D.docx - -
- -
-
- report-3
-
-
-
-
- - report-3A.docx - -
- - report-3B.docx - -
- - report-3C.docx - -
- - report-3D.docx - -
-
- -
-
- report-1
-
-
-
-
- Letters
-
-
-
-
-
-
- letter-1
-
-
-
-
- - letter-1A.docx - -
- - letter-1B.docx - -
- - letter-1C.docx - -
- -
-
- letter-2
-
-
-
-
- - letter-2A.docx - -
- - letter-2B.docx - -
- - letter-2C.docx - -
- - letter-2D.docx - -
- -
-
- letter-3
-
-
-
-
- - letter-3A.docx - -
- - letter-3B.docx - -
- - letter-3C.docx - -
- - letter-3D.docx - -
-
- -
-
- letter-1
-
-
-
+
+ Projects
+
+
-
+
- + project-1.docx + +
- + project-2.docx + +
-
+
+ project-3
+
+
-
+
- + project-3A.docx + +
- + project-3B.docx + +
- + project-3C.docx + +
+ - + project-4.docx + +
-
+
+ project-5
+
+
-
+
- + project-5A.docx + +
- + project-5B.docx + +
- + project-5C.docx + +
- + project-5D.docx + +
- + project-5E.docx + +
- + project-5F.docx + +
+
+ -
+
+ Reports
+
+
-
+
-
+
+ report-1
+
+
-
+
- + report-1A.docx + +
- + report-1B.docx + +
- + report-1C.docx + +
+ -
+
+ report-2
+
+
-
+
- + report-2A.docx + +
- + report-2B.docx + +
- + report-2C.docx + +
- + report-2D.docx + +
+ -
+
+ report-3
+
+
-
+
- + report-3A.docx + +
- + report-3B.docx + +
- + report-3C.docx + +
- + report-3D.docx + +
+
+ -
+
+ report-1
+
+
-
+
+ Letters
+
+
-
+
-
+
+ letter-1
+
+
-
+
- + letter-1A.docx + +
- + letter-1B.docx + +
- + letter-1C.docx + +
+ -
+
+ letter-2
+
+
-
+
- + letter-2A.docx + +
- + letter-2B.docx + +
- + letter-2C.docx + +
- + letter-2D.docx + +
+ -
+
+ letter-3
+
+
-
+
- + letter-3A.docx + +
- + letter-3B.docx + +
- + letter-3C.docx + +
- + letter-3D.docx + +
+
+ -
+
+ letter-1
+
+
Example
-File Viewer
--
-
My Documents
+-
+
File Viewer
Accessibility Features
- To make the focus indicator easier to see, nodes in the tree have a custom focus and hover styling created using CSS focus and hover pseudo-classes. + To make the focus indicator easier to see, nodes in the tree have custom focus and hover styling created using CSS focus and hover pseudo-classes.
Terms Used to Describe Trees
Keyboard Support
++ Note that in this example, selection and focus are distinct; moving focus does not change which node is selected. + Because selection does not follow focus, keyboard and screen reader users can navigate and explore the tree without changing the content of the file viewer. + To learn more about this aspect of the design, read the guidance section about Deciding When to Make Selection Automatically Follow Focus. +
Enter or Space |
-
-
|
+ |||
---|---|---|---|---|
Enter | +Performs the default action, which is to select the node, causing the name of the node to appear in the File or Folder Selectedtextbox. |
+ |||
Space | +Performs the default action, which is to select the node, causing the name of the node to appear in the File or Folder Selectedtextbox. |
|||
Down arrow | @@ -552,7 +605,7 @@||||
- | aria-labelledby="IDREF" |
+ aria-labelledby="ID_REFERENCE" |
ul |
Refers to the heading element that contains the label that identifies the purpose of the tree . |
- | tabindex="-1" |
+ tabindex="-1" |
li |
Role, Property, State, and Tabindex Attributes |
- | tabindex="0" |
+ tabindex="0" |
li |
|
- | aria-expanded="false" |
+ aria-expanded="false" |
li |
Role, Property, State, and Tabindex Attributes |
- | aria-expanded="true" |
+ aria-expanded="true" |
li |
Role, Property, State, and Tabindex Attributes |
+ | aria-selected="false" |
+ li |
+
+
|
+ |
+ | aria-selected="true" |
+ li |
+
+
|
+ |
- | aria-setsize="number" |
+ aria-setsize="number" |
li |
Defines the number of treeitem elements in the set of treeitem elements that are in the same branch and at the same level within the hierarchy. |
- | aria-posinset="number" |
+ aria-posinset="number" |
li |
Role, Property, State, and Tabindex Attributes |
- | aria-level="number" |
+ aria-level="number" |
li |
|
Javascript and CSS Source Code
-
@@ -686,7 +761,6 @@
HTML Source Code
-