Skip to content

Commit aa50708

Browse files
committed
fix: update aria-label in TableOfContentsItems for improved accessibility
1 parent cc5fce7 commit aa50708

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/components/table-of-contents.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ import usePage from '../hooks/use-page'
66

77
const TableOfContentsItems = ({items, depth}) => (
88
<>
9-
{items.map(item => (
9+
{items.map((item, index) => (
1010
<React.Fragment key={item.title}>
1111
<NavList.Item
1212
href={item.url}
13-
sx={{pl: depth > 1 ? 4 : 2}}
14-
aria-label={`${item.title}${depth > 1 ? ` in ${item.title}` : ''} 10 of 200`}
13+
aria-label={`${item.title}, ${index + 1} of ${items.length}`}
14+
aria-labelledby={null}
1515
>
1616
{item.title}
17+
{item.items ? (
18+
<NavList.SubNav>
19+
<TableOfContentsItems items={item.items} depth={depth + 1} />
20+
</NavList.SubNav>
21+
) : null}
1722
</NavList.Item>
18-
{item.items ? <TableOfContentsItems items={item.items} depth={depth + 1} /> : null}
1923
</React.Fragment>
2024
))}
2125
</>

0 commit comments

Comments
 (0)