Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard interaction and ARIA roles #9

Closed
angrycat9000 opened this issue Mar 21, 2022 · 5 comments · Fixed by #49
Closed

Add keyboard interaction and ARIA roles #9

angrycat9000 opened this issue Mar 21, 2022 · 5 comments · Fixed by #49

Comments

@angrycat9000
Copy link

I saw your post on reddit. Nice tree control.

I wanted to give a suggestion that could help take it to the next level. Right now it is very mouse oriented. However, not everyone may prefer to use the mouse. If you look up the the tree role on MDN it documents keyboard interactions for a tree. That way users can operate it without taking their hands off the keyboard if they prefer (similar to Ctrl-C Ctrl-V for copy and paste).

@jameskerr
Copy link
Member

Thank you for your kindly worded suggestion.I plan to work on this very soon. This also came up on hacker news.

@esmevane
Copy link

If you're looking for prior art which might be helpful, React-Aria has some examples of hook-based aria implementations. Even when just used as implementation guides, it's been useful for me.

@Pustelto
Copy link

Definitely +1 for this. I haven't found a tree component which would support all the use-cases you have. The a11y is the only missing thing for me. Then I can remove this from my should-do-in-the-future OSS list.

Here is the really good writeup how the tree should behave and what roles it should have: https://www.w3.org/TR/wai-aria-practices-1.1/#TreeView

@jameskerr
Copy link
Member

Thanks @Pustelto! I'll reference that as I work on it.

This was referenced Mar 25, 2022
@jameskerr
Copy link
Member

jameskerr commented Mar 29, 2022

Here's a todo list for this issue:

Keyboard Events

  • Right Arrow
  • When focus is on a closed node, opens the node; focus does not move.
  • When focus is on a open node, moves focus to the first child node.
  • When focus is on an end node (a tree item with no children), does nothing.
  • Left Arrow
  • When focus is on an open node, closes the node.
  • When focus is on a child node that is also either an end node or a closed node, moves focus to its parent node.
  • When focus is on a closed tree, does nothing.
  • Down Arrow
  • Moves focus to the next node that is focusable without opening or closing a node.
  • Up Arrow
  • Moves focus to the previous node that is focusable without opening or closing a node.
  • Home
  • Moves focus to the first node in the tree without opening or closing a node.
  • End
  • Moves focus to the last node in the tree that is focusable without opening the node.
  • Enter
  • Edits the focused node
  • Type characters
  • Focus moves to the next node with a name that starts with the typed character.
  • If multiple characters are typed in rapid succession, focus moves to the next node with a name that starts with the string of characters typed.
  • *
  • Expands all siblings that are at the same level as the current node.

Multi Selection

  • Space
  • Toggles the selection state of the focused node.
  • Shift + Down Arrow
  • Moves focus to and toggles the selection state of the next node.
  • Shift + Up Arrow
  • Moves focus to and toggles the selection state of the previous node.
  • Shift + Space
  • Selects contiguous nodes from the most recently selected node to the current node.
  • Control + Shift + Home
  • Selects the node with focus and all nodes up to the first node. Optionally, moves focus to the first node
  • Control + Shift + End
  • Selects the node with focus and all nodes down to the last node. Optionally, moves focus to the last node.
  • Control + A
  • Selects all nodes in the tree. Optionally, if all nodes are selected, it can also unselect all nodes.

ARIA Roles

@jameskerr jameskerr mentioned this issue Oct 18, 2022
19 tasks
jameskerr added a commit that referenced this issue Oct 20, 2022
Keyboard navigation
 Aria Roles fixes (fixes #9)
 Smart "scrollTo" behavior
 Automatically sync selection
 Tree filtering now handled by arborist
 Moves "openness" state into the tree with an "initialOpens" prop
 Simple NodeApi class for use in the node renderer
 Ability to specify the drag handler (fixes #38)
 Splits the NodeRenderer into a RowRenderer and a NodeRenderer with defaults resulting in less boilerplate. (fixes #8)
 Adds an onActivate callback
 Adds an onSelect callback (fixes #44)
 Adds an onCreate callback
 Adds an onDelete callback
 Adds an onScroll callback (fixes #30)
 Improved abstractions for focus, selection, and activation (fixes #1, fixes #6)
 Fixes the bug where you can drag a parent into itself (fixes #41)
fixes #46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants