Skip to content

Commit 41684d0

Browse files
authored
Revert "Automatically scroll to the active page in table of contents (#2425) (#2429)
1 parent 9f6c334 commit 41684d0

File tree

4 files changed

+3
-74
lines changed

4 files changed

+3
-74
lines changed

.changeset/stupid-guests-drive.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/gitbook/src/components/TableOfContents/TableOfContents.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { tcls } from '@/lib/tailwind';
1414

1515
import { PagesList } from './PagesList';
1616
import { Trademark } from './Trademark';
17-
import { TOCScrollContainerProvider } from './useScrollToActiveTOCItem';
1817

1918
export function TableOfContents(props: {
2019
space: Space;
@@ -56,7 +55,7 @@ export function TableOfContents(props: {
5655
)}
5756
>
5857
{header ? header : null}
59-
<TOCScrollContainerProvider
58+
<div
6059
className={tcls(
6160
withHeaderOffset ? 'pt-4' : ['pt-4', 'lg:pt-0'],
6261
'hidden',
@@ -88,7 +87,7 @@ export function TableOfContents(props: {
8887
{customization.trademark.enabled ? (
8988
<Trademark space={space} customization={customization} />
9089
) : null}
91-
</TOCScrollContainerProvider>
90+
</div>
9291
</aside>
9392
);
9493
}

packages/gitbook/src/components/TableOfContents/ToggleableLinkItem.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import React from 'react';
77

88
import { tcls } from '@/lib/tailwind';
99

10-
import { useScrollToActiveTOCItem } from './useScrollToActiveTOCItem';
1110
import { Link } from '../primitives';
1211

1312
const show = {
@@ -47,7 +46,6 @@ export function ToggleableLinkItem(props: {
4746

4847
const [scope, animate] = useAnimate();
4948
const [isVisible, setIsVisible] = React.useState(hasActiveDescendant);
50-
const linkRef = React.createRef<HTMLAnchorElement>();
5149

5250
// Update the visibility of the children, if we are navigating to a descendant.
5351
React.useEffect(() => {
@@ -92,15 +90,12 @@ export function ToggleableLinkItem(props: {
9290
const mountedRef = React.useRef(false);
9391
React.useEffect(() => {
9492
mountedRef.current = true;
95-
});
96-
97-
useScrollToActiveTOCItem({ linkRef, isActive });
93+
}, []);
9894

9995
return (
10096
<div>
10197
<Link
10298
href={href}
103-
ref={linkRef}
10499
aria-selected={isActive}
105100
className={tcls(
106101
'group/toclink',

packages/gitbook/src/components/TableOfContents/useScrollToActiveTOCItem.tsx

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)