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

Tree View: Selected item should not regain focus when reentering the tree. #1751

Closed
Jonas-C opened this issue Aug 9, 2024 · 1 comment
Closed

Comments

@Jonas-C
Copy link
Contributor

Jonas-C commented Aug 9, 2024

🐛 Bug report

The Tree View always returns focus to the selected element when regaining focus. This could lead to the entire tree being skipped if the selected element is not yet expanded.

💥 Steps to reproduce

Two related errors:

Focus regained at wrong location

  1. Tab to the tree view.
  2. Use arrow keys to navigate to item 1.1. Select it with enter.
  3. Use arrow keys to navigate to item 1.2. Tab away from the component, and then shift-tab back to it.
  4. Focus is on 1.1, but should be on 1.2.

Tree view skipped

  1. Tab to the tree view.
  2. Use arrow keys to navigate to item 1.1. Select it with enter.
  3. Use arrow keys to navigate to item 1. Collapse it with ArrowLeft.
  4. Tab away from the component, and then shift-tab back to it. The entire tree is skipped.

💻 Link to reproduction

https://ark-ui.com/react/docs/components/tree-view

🧐 Expected behavior

I'd expect the focus handling to follow the w3 examples.

🧭 Possible Solution

Do not clear focus state when blurring the tree. I don't really see a reason to do any blur actions for the tree whatsoever.

🌍 System information

Software Version(s)
Zag Version 0.65.0
Browser Firefox
Operating System MacOS

📝 Additional information

https://www.w3.org/WAI/ARIA/apg/patterns/treeview/examples/treeview-1a/

Aside: There's no zag documentation on the tree component. Is that intended?

@segunadebayo
Copy link
Member

I just pushed a fix for this. We'll release an update shortly.

If the issue persists after upgrading, I'll re-open it.

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

No branches or pull requests

2 participants