From 2f97a854065c0f0d1f5cad9a8a933cfcc41265a9 Mon Sep 17 00:00:00 2001 From: Devtato Date: Thu, 13 Jan 2022 07:04:57 +0000 Subject: [PATCH] feat(theme-classic): autoscroll TOC with active link (#6317) * feat(theme-common): add smooth TOC scrolling to active link * docs: change the link of repeated content category in lifecycle api * Update lifecycle-apis.md * fix page container scrolling Co-authored-by: Joshua Chen --- packages/docusaurus-theme-common/src/utils/useTOCHighlight.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/docusaurus-theme-common/src/utils/useTOCHighlight.ts b/packages/docusaurus-theme-common/src/utils/useTOCHighlight.ts index 2283176e0250..fa5d54ba4c40 100644 --- a/packages/docusaurus-theme-common/src/utils/useTOCHighlight.ts +++ b/packages/docusaurus-theme-common/src/utils/useTOCHighlight.ts @@ -144,6 +144,7 @@ function useTOCHighlight(config: TOCHighlightConfig | undefined): void { } link.classList.add(linkActiveClassName); lastActiveLinkRef.current = link; + link.scrollIntoView({block: 'nearest'}); } else { link.classList.remove(linkActiveClassName); }