-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: Speed up tree navigation by returning to parent when collapsing… #9547
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
base: main
Are you sure you want to change the base?
Conversation
|
thanks for the PR you can run lint and tests via To run the tests on other versions of react you should do |
I had odd behaviour with I also understand that your ESLint config does not have formatting rules, is that correct? If so, is there a formatting command or preferred IDE setup? My IDE autoformatting made a mess on my branch.
Thanks! I did manage to run the tests, but they fail and I'm not sure why. The story I added shows the feature to work, but I suspect the test setup is slightly different, and probably involves some layers of code that I haven't accounted for. I'll need guidance to move forward on that. |
Nope, nothing special should be needed, you should be able to
Some things that might affect it:
yes, we frequently run |
Oddly enough, running ESLint locally does not fix whitespace issues for me. But hey, CI told me what was missing :)
I found the issue 😬 that test was poorly written. I had to remove the |
snowystinger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates
|
|
||
| By default, pressing the collapse key (<Keyboard>←</Keyboard> in LTR, <Keyboard>→</Keyboard> in RTL) on an expanded item will collapse it. The key will do nothing on non-collapsible items. The same key is used to navigate between the actions within tree items. | ||
|
|
||
| The `shouldNavigateToCollapsibleParent` prop enables a faster navigation behavior: when the collapse key is pressed on a leaf item or an already collapsed parent, focus moves to that item's parent. This helps users quickly navigate up the tree without needing to manually navigate to each parent item. But it has a trade-off: users can no longer use that key to cycle through actions on the current item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really accurate, you can still use the arrow keys to cycle through actions, it's only if the focus is on the row, it won't wrap to the end of the actions. But if you're among the actions already, then it works just fine.
|
|
||
| The `<TreeItem>` component works with frameworks and client side routers like [Next.js](https://nextjs.org/) and [React Router](https://reactrouter.com/en/main). As with other React Aria components that support links, this works via the <TypeLink links={docs.links} type={docs.exports.RouterProvider} /> component at the root of your app. See the [client side routing guide](routing.html) to learn how to set this up. | ||
|
|
||
| ## Keyboard navigation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question to the team, do we want a prop for this, or should this just be the default for all trees?
| - Pressing collapse on a leaf item moves focus to its parent | ||
| - Pressing collapse on an expanded item collapses it | ||
| - Pressing collapse again on a collapsed item moves focus to its parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does "pressing" mean here? clicking on the arrow with your mouse, the keyboard arrow keys?
I don't really have a better suggestion yet, maybe we can just remove this section
… a non-collapsible item
Closes #9546
To address the issue, I add a new opt-in prop to
useTreeStatethat enables the behaviour supported by Primer and the APG, and which we know our users will need (as our own tree implementation, which we want to replace with RAC Tree, currently has it).✅ Pull Request Checklist:
Caution
Please note! I do not know how to run your linter, how to see the RAC Tree documentation, and there are failing tests (though I do not understand the subtleties of KeyboardDelegates and don't understand how to fix them).
I have likely forgotten some code paths in my PR.
📝 Test Instructions:
https://localhost:?????/?path=/story/react-aria-components-tree--nav-to-nearest-collapsible-parent🧢 Your Project:
https://github.com/storybookjs/storybook