-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -701,6 +701,26 @@ Tree items may also be links to another page or website. This can be achieved by | |
|
|
||
| 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 | ||
|
|
||
| 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
|
||
| ```tsx example | ||
| <FileTree | ||
| shouldNavigateToCollapsibleParent | ||
| selectionMode="single" | ||
| defaultExpandedKeys={['1', '2']} | ||
| defaultSelectedKeys={['5']} | ||
| /> | ||
| ``` | ||
|
|
||
| With this prop enabled: | ||
| - 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 | ||
|
Comment on lines
+720
to
+722
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
|
||
| ## Disabled items | ||
|
|
||
| A `TreeItem` can be disabled with the `isDisabled` prop. This will disable all interactions on the 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.
Question to the team, do we want a prop for this, or should this just be the default for all trees?