@@ -3,7 +3,7 @@ import { TreeView, TreeViewItem } from "@/components/TreeView";
3
3
import { chevron } from "@/icons/chevron" ;
4
4
import { useSuspenseQuery } from "@tanstack/react-query" ;
5
5
import clsx from "clsx" ;
6
- import { useState , useTransition } from "react" ;
6
+ import { useId , useState , useTransition } from "react" ;
7
7
import { To , useHref , useLinkClickHandler } from "react-router-dom" ;
8
8
9
9
import { NestedItem , transformStructure } from "../docsSidebar" ;
@@ -55,12 +55,17 @@ function DocsTreeViewItem({
55
55
const { lang } = useProviderParams ( ) ;
56
56
const [ open , setOpen ] = useState ( isOpenByDefault ) ;
57
57
let button ;
58
+ const listId = useId ( ) ;
59
+ const buttonId = useId ( ) ;
58
60
59
61
if ( item . items ) {
60
62
button = (
61
63
< button
62
64
className = "flex gap-2 px-4 py-2 text-left text-inherit hover:bg-gray-100 dark:hover:bg-blue-900"
63
65
onClick = { ( ) => setOpen ( ! open ) }
66
+ aria-expanded = { open }
67
+ aria-controls = { open ? listId : undefined }
68
+ id = { buttonId }
64
69
>
65
70
< Icon
66
71
path = { chevron }
@@ -86,7 +91,7 @@ function DocsTreeViewItem({
86
91
< TreeViewItem nested = { nested } className = { nested ? "ml-2" : "" } >
87
92
{ button }
88
93
{ open && item . items && (
89
- < TreeView className = "ml-4" >
94
+ < TreeView className = "ml-4" id = { listId } aria-labelledby = { buttonId } >
90
95
{ item . items . map ( ( subitem ) => (
91
96
< DocsTreeViewItem
92
97
key = { subitem . name }
0 commit comments