From d645860f869a1ce38f94aba7bdce568a946ea6e7 Mon Sep 17 00:00:00 2001 From: vaani1127 Date: Wed, 21 Jan 2026 01:22:31 +0530 Subject: [PATCH 1/2] feat: add scrollbar to Table of Contents for long articles Signed-off-by: vaani1127 --- components/TableContents.tsx | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/components/TableContents.tsx b/components/TableContents.tsx index 17906219..bbf426cb 100644 --- a/components/TableContents.tsx +++ b/components/TableContents.tsx @@ -68,19 +68,19 @@ export default function TOC({ headings, isList, setIsList }) { const handleItemClick = (id) => { - const sanitizedId = sanitizeStringForURL(id, true); - const element = document.getElementById(sanitizedId); - if (element) { - const offset = 80; - const offsetPosition = element.offsetTop - offset; - window.scrollTo({ - top: offsetPosition, - behavior: "smooth", - }); - - window.history.replaceState(null, null, `#${sanitizedId}`); - } -}; + const sanitizedId = sanitizeStringForURL(id, true); + const element = document.getElementById(sanitizedId); + if (element) { + const offset = 80; + const offsetPosition = element.offsetTop - offset; + window.scrollTo({ + top: offsetPosition, + behavior: "smooth", + }); + + window.history.replaceState(null, null, `#${sanitizedId}`); + } + }; // State to track screen width const [isSmallScreen, setIsSmallScreen] = useState(false); @@ -202,7 +202,7 @@ export default function TOC({ headings, isList, setIsList }) { ))} ) : ( -