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

fix keyboarding behavior for right and left arrow keys in Tree View #5899

Merged
merged 5 commits into from
Apr 28, 2022

Conversation

chrisdholt
Copy link
Member

Pull Request

📖 Description

This PR fixes the left and right arrow behaviors to match those enumerated in the ARIA Authoring Practices document.

Right Arrow behavior:

  • 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, does nothing.

Left Arrow behavior:

  • 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 root node that is also either an end node or a closed node, does nothing.

🎫 Issues

fixes #5630

👩‍💻 Reviewer Notes

If you pull down, test and run fast-components, you should see the behavior above for tree items.

📑 Test Plan

There are no test for keyboarding behavior currently - we need to add this (ideally w/ playwright)

✅ Checklist

General

  • I have included a change request file using $ yarn change
  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

⏭ Next Steps

@chrisdholt chrisdholt force-pushed the users/chhol/fix-left-arrow-key-behavior-tree-item branch from b8da96f to f169ace Compare April 27, 2022 05:52
Comment on lines +151 to +155
if (
item instanceof TreeItem &&
item.childItemLength() > 0 &&
item.expanded
) {
Copy link
Member Author

@chrisdholt chrisdholt Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left arrow on an open parent node closes the node without moving focus.

Comment on lines +157 to 162
} else if (
item instanceof TreeItem &&
item.parentElement instanceof TreeItem
) {
TreeItem.focusItem(item.parentElement);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left arrow on either a child node or a closed node moves focus to its parent (if one exists).

Comment on lines +168 to 173
if (
item instanceof TreeItem &&
item.childItemLength() > 0 &&
!item.expanded
) {
item.expanded = true;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right arrow on a closed node expands the node without moving focus.

Comment on lines +174 to +175
} else if (item instanceof TreeItem && item.childItemLength() > 0) {
this.focusNextNode(1, e.target as TreeItem);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right arrow on expanded parent node focus its first child node.

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://purple-ocean-0b7ce3410-5899.centralus.azurestaticapps.net

2 similar comments
@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://purple-ocean-0b7ce3410-5899.centralus.azurestaticapps.net

@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://purple-ocean-0b7ce3410-5899.centralus.azurestaticapps.net

Copy link
Collaborator

@scomea scomea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smoked, works as expected.

@chrisdholt chrisdholt added the fast-components:final Issues or PR's to include in the final release of fast-components label Apr 27, 2022
@ghost
Copy link

ghost commented Apr 28, 2022

CLA assistant check
All CLA requirements met.

@chrisdholt chrisdholt merged commit 5db7249 into master Apr 28, 2022
@chrisdholt chrisdholt deleted the users/chhol/fix-left-arrow-key-behavior-tree-item branch April 28, 2022 20:44
huynhicode pushed a commit that referenced this pull request Apr 29, 2022
…5899)

* fix keyboarding behavior for right and left arrow keys in Tree View

* Change files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fast-components:final Issues or PR's to include in the final release of fast-components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: left arrow key event on tree item leaf is broken in @microsoft/foundation
3 participants