Note: This is a follow up to the File Explorer question, you should complete that question first before attempting this question.

A tree view widget presents a hierarchical list. Any item in the hierarchy may have child items, and items that have children may be expanded or collapsed to show or hide the children. For example, in a file system navigator that uses a tree view to display folders and files, an item representing a folder can be expanded to reveal the contents of the folder, which may be files, folders, or both.

Source: Tree View Pattern

In File Explorer, we built a functional file explorer component that displays an array of file objects in a hierarchical tree format. However, building good UI components goes beyond functionality and we have to ensure our components have great accessibility as well by adding the right ARIA roles, states, and properties to the DOM elements.

Requirements

The ARIA Authoring Practices Guide has a long list of guidelines for the ARIA roles, states, and properties to add to the various elements of a Tree View pattern.

Implement the following ARIA guidelines for this question:

Notes

The skeleton code uses the solution of File Explorer, but you are free to use your own solution as a starting point.

Solution

We'll build on top of File Explorer's solution.

FileExplorer component