From e028f6f93af7c9e726d30b7d11fb671964d093ed Mon Sep 17 00:00:00 2001 From: xiezhouwei Date: Mon, 22 Jun 2026 09:56:23 +0800 Subject: [PATCH] fix: adjust docs page scroll offset to prevent fixed header occlusion --- web/src/pages/Docs/index.jsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web/src/pages/Docs/index.jsx b/web/src/pages/Docs/index.jsx index e4e1b06..83c9b52 100644 --- a/web/src/pages/Docs/index.jsx +++ b/web/src/pages/Docs/index.jsx @@ -85,7 +85,7 @@ function CodeBlock({ code, lang = 'bash' }) { /* ─── SectionTitle ─── */ function SectionTitle({ id, icon: Icon, children }) { return ( -

+

@@ -152,6 +152,9 @@ export default function Docs() { const [sidebarOpen, setSidebarOpen] = useState(false); const contentRef = useRef(null); + // Header height offset (56px header + 16px breathing room) + const HEADER_OFFSET = 72; + // Scroll spy useEffect(() => { const observer = new IntersectionObserver( @@ -163,7 +166,7 @@ export default function Docs() { } } }, - { rootMargin: '-80px 0px -70% 0px', threshold: 0 } + { rootMargin: `-${HEADER_OFFSET}px 0px -70% 0px`, threshold: 0 } ); const ids = DOC_SECTIONS.map((s) => s.id); @@ -177,7 +180,10 @@ export default function Docs() { const scrollTo = (id) => { setSidebarOpen(false); - document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' }); + const el = document.getElementById(id); + if (!el) return; + const top = el.getBoundingClientRect().top + window.scrollY - HEADER_OFFSET; + window.scrollTo({ top, behavior: 'smooth' }); }; const BASE_HOST = window.location.origin;