-
Notifications
You must be signed in to change notification settings - Fork 638
Closed
Labels
component: TreeViewIssues related to the TreeView componentIssues related to the TreeView componentdesignneeds design input
Description
Description
Hi there,
I'm on the Docs team here at GitHub, and we're currently using the TreeView Component for navigation links with Next.js in a similar way to this example.
We are using our own NextJS Link Component with TreeView. This has been working great for our use case except for the fact that it's not keyboard accessible. On keyboard press Enter, it does not route to the href
as expected as when you click.
The TreeView component has been a great for our sidebar in terms of usability and design and we'd love if it could be keyboard accessible with navigation links.
Steps to reproduce
Given the Next.js example, swap out Link
with an a
tag:
function TreeLinkItem({id, href, children}) {
const router = useRouter()
const isCurrent = typeof href === 'string' ? router.asPath === href : router.pathname === href.pathname
return (
<a href={href}>
<TreeView.Item id={id} aria-current={isCurrent ? 'page' : false} current={isCurrent}>
{children}
</TreeView.Item>
</a>
)
}
Use tab to focus on the TreeView item and press Enter on your keyboard.
Press Enter and you will not be routed.
Version
v35.2.0
Browser
Chrome
Metadata
Metadata
Assignees
Labels
component: TreeViewIssues related to the TreeView componentIssues related to the TreeView componentdesignneeds design input