Skip to content

Commit 9e21836

Browse files
authored
Revert "Accessibility: Nesting headingLevel 3 mini tocs (#23663)" (#23759)
This reverts commit 41c7f58.
1 parent 45f1a41 commit 9e21836

2 files changed

Lines changed: 6 additions & 18 deletions

File tree

components/article/ArticlePage.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { useRouter } from 'next/router'
2-
import { useState } from 'react'
32
import cx from 'classnames'
43
import { ActionList, Heading } from '@primer/components'
54

6-
import { ChevronDownIcon, ZapIcon, InfoIcon, ShieldLockIcon } from '@primer/octicons-react'
5+
import { ZapIcon, InfoIcon, ShieldLockIcon } from '@primer/octicons-react'
76
import { Callout } from 'components/ui/Callout'
87

98
import { Link } from 'components/Link'
@@ -61,9 +60,8 @@ export const ArticlePage = () => {
6160
} = useArticleContext()
6261
const { t } = useTranslation('pages')
6362
const currentPath = router.asPath.split('?')[0]
64-
const [isActive, setActive] = useState(-1)
6563

66-
const renderTocItem = (item: MiniTocItem, index: number) => {
64+
const renderTocItem = (item: MiniTocItem) => {
6765
return (
6866
<ActionList.Item
6967
as="li"
@@ -72,19 +70,9 @@ export const ArticlePage = () => {
7270
sx={{ listStyle: 'none', padding: '2px' }}
7371
>
7472
<div className={cx('lh-condensed d-block width-full')}>
75-
<div className="d-inline-flex" dangerouslySetInnerHTML={{ __html: item.contents }} />
76-
{item.items && item.items.length > 0 && (
77-
<button
78-
className="color-bg-default border-0 ml-1"
79-
onClick={() => setActive(index === isActive ? -1 : index)}
80-
>
81-
{<ChevronDownIcon />}
82-
</button>
83-
)}
73+
<div dangerouslySetInnerHTML={{ __html: item.contents }} />
8474
{item.items && item.items.length > 0 ? (
85-
<ul className={index === isActive ? 'ml-3' : 'd-none'}>
86-
{item.items.map(renderTocItem)}
87-
</ul>
75+
<ul className="ml-3">{item.items.map(renderTocItem)}</ul>
8876
) : null}
8977
</div>
9078
</ActionList.Item>
@@ -158,7 +146,7 @@ export const ArticlePage = () => {
158146
return {
159147
key: title + i,
160148
text: title,
161-
renderItem: () => <ul>{renderTocItem(items, i)}</ul>,
149+
renderItem: () => <ul>{renderTocItem(items)}</ul>,
162150
}
163151
})}
164152
/>

tests/rendering/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ describe('server', () => {
344344
)
345345
expect($('h2#in-this-article').length).toBe(1)
346346
expect($('h2#in-this-article + div div ul').length).toBeGreaterThan(0) // non-indented items
347-
expect($('h2#in-this-article + div div ul li div div div ul li').length).toBeGreaterThan(0) // indented items
347+
expect($('h2#in-this-article + div div ul li div div div ul.ml-3').length).toBeGreaterThan(0) // indented items
348348
})
349349

350350
test('does not render mini TOC in articles with only one heading', async () => {

0 commit comments

Comments
 (0)