From 9f3bdc14fd2d7c95046263e8ee51c574359a4ec7 Mon Sep 17 00:00:00 2001 From: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:35:18 +0000 Subject: [PATCH 1/4] Mark the current page in the reference sidebar trailingSlash: true gives usePathname() a trailing slash that the sidebar's hrefs lack, so no entry has matched since, and the sidebar never scrolled to the current one. Signed-off-by: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> --- app/components/Index.tsx | 6 +++++- tests/referenceIndex.test.tsx | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/referenceIndex.test.tsx diff --git a/app/components/Index.tsx b/app/components/Index.tsx index 2dbba7d8..4a34dd49 100644 --- a/app/components/Index.tsx +++ b/app/components/Index.tsx @@ -40,7 +40,8 @@ export default function Index({ }: { groupedReferences: Record>; }) { - const pathname = usePathname(); + // trailingSlash: true makes this "/x/", but the hrefs compared below have no slash + const pathname = usePathname().replace(/\/+$/, ''); const activeItemRef = useRef(null); const containerRef = useRef(null); @@ -114,6 +115,7 @@ export default function Index({ ({ value: '' })); +vi.mock('next/navigation', () => ({ usePathname: () => pathname.value })); + +import Index from '../app/components/Index'; + +const item = (name: string) => ({ name, description: '', reference: `operators/accumulators/${name}`, type: 'operators', category: 'accumulators' }); +const groupedReferences = { operators: { accumulators: [item('$avg'), item('$sum')] } }; + +function currentLinks(path: string) { + pathname.value = path; + const html = renderToStaticMarkup(createElement(Index, { groupedReferences })); + return [...html.matchAll(/]*aria-current="page"[^>]*>([^<]*)<\/a>/g)].map((match) => match[1]); +} + +describe('Reference sidebar current page', () => { + // trailingSlash: true serves every page at "/x/"; the static render sees "%24", the browser "$" + it('marks exactly the current entry', () => { + expect(currentLinks('/docs/reference/operators/accumulators/%24avg/')).toEqual(['$avg']); + expect(currentLinks('/docs/reference/operators/accumulators/$avg/')).toEqual(['$avg']); + expect(currentLinks('/docs/reference/operators/accumulators/')).toEqual(['Accumulators']); + expect(currentLinks('/docs/reference/operators/')).toEqual(['Operators']); + }); +}); From c3c614934e75048e55cac66317c56864519376b7 Mon Sep 17 00:00:00 2001 From: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:35:18 +0000 Subject: [PATCH 2/4] Scroll reference pages with the window, with a sticky sidebar The 100vh pane started below the banner and navbar, so its last ~100px sat below the fold, the window and the article scrolled separately, and the navbar covered the pane's top once the window moved. Signed-off-by: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> --- app/docs/reference/layout.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/docs/reference/layout.tsx b/app/docs/reference/layout.tsx index e5ea4381..5ae97965 100644 --- a/app/docs/reference/layout.tsx +++ b/app/docs/reference/layout.tsx @@ -17,9 +17,9 @@ export default function ReferenceLayout({ }>) { const groupedReferences = getReferencesGroupedByTypeAndCategory(); - // Phones get no sidebar, so the page scrolls rather than a 100vh pane half under the navbar + // overflow-clip, not hidden: hidden makes a scroll container and the sidebar would stop sticking return ( -
+
{/* Background elements */}
@@ -29,9 +29,9 @@ export default function ReferenceLayout({ style={{ animationDelay: "1.5s" }} >
-
- {/* Sidebar (desktop only; mobile gets the disclosure below) */} -
+
+ {/* Sidebar (desktop only; mobile gets the disclosure below), held under the 4rem navbar */} +
-
+
{/* Mobile reference navigation */}
From c99d456b18233ab2d4735ee05a7228d6c539a5b2 Mon Sep 17 00:00:00 2001 From: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:35:18 +0000 Subject: [PATCH 3/4] Render
in Markdown as a line break react-markdown prints raw HTML as text, so the $densify Limitations table showed literal
. Only
is converted; other HTML stays escaped. Signed-off-by: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> --- app/components/Markdown.tsx | 17 +++++++++++++++-- tests/markdownBasePath.test.tsx | 9 +++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/components/Markdown.tsx b/app/components/Markdown.tsx index a480d056..e9cc1cc7 100644 --- a/app/components/Markdown.tsx +++ b/app/components/Markdown.tsx @@ -15,6 +15,19 @@ interface MarkdownProps { sourcePath: string; } +// GFM table cells can't hold newlines, so docs break lines with
; render that one tag, not raw HTML. +function remarkBrTags() { + return (tree: any) => { + const visit = (node: any) => node.children?.forEach((child: any, i: number) => { + if (child.type === 'html' && /^$/i.test(child.value)) node.children[i] = { type: 'break' }; + else visit(child); + }); + visit(tree); + }; +} + +const remarkPlugins = [remarkGfm, remarkBrTags]; + export default function Markdown({ content, sourcePath }: MarkdownProps) { const processedContent = useMemo(() => { // Split content by H2 headings to group sections @@ -29,7 +42,7 @@ export default function Markdown({ content, sourcePath }: MarkdownProps) { elements.push(
{section} @@ -49,7 +62,7 @@ export default function Markdown({ content, sourcePath }: MarkdownProps) { {title} {sectionContent} diff --git a/tests/markdownBasePath.test.tsx b/tests/markdownBasePath.test.tsx index c0b720b4..f9dcafb2 100644 --- a/tests/markdownBasePath.test.tsx +++ b/tests/markdownBasePath.test.tsx @@ -41,3 +41,12 @@ describe('Markdown heading anchors', () => { } }); }); + +describe('Markdown table cells', () => { + it('turns
into a line break but keeps other HTML escaped', async () => { + const html = await render('| a | b |\n| --- | --- |\n| x
y
z | bold |'); + expect(html.match(//g)).toHaveLength(2); + expect(html).not.toContain('<br'); + expect(html).toContain('<b>bold</b>'); + }); +}); From e521e4a13b6aadfb1cc67e232e6243997a60b379 Mon Sep 17 00:00:00 2001 From: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> Date: Fri, 6 Nov 2026 16:35:18 +0000 Subject: [PATCH 4/4] Fit the mobile menu to the screen and close it on navigation The open menu had no height limit inside the sticky nav, so on short screens its last links were out of reach. It also stayed open after Escape, the logo, or Back. Signed-off-by: Guanzhou Song <26541184+GuanzhouSong@users.noreply.github.com> --- app/components/Navbar.tsx | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/app/components/Navbar.tsx b/app/components/Navbar.tsx index adda0c81..bcf2fb56 100644 --- a/app/components/Navbar.tsx +++ b/app/components/Navbar.tsx @@ -3,6 +3,7 @@ import { useEffect, useRef, useState, type ReactNode } from "react"; import Image from "next/image"; import Link from "next/link"; +import { usePathname } from "next/navigation"; // The Jekyll layout renders the same file, so the blog and announcement pages show this nav too import nav from "../../blogs/_data/nav.json"; import { withBasePath } from "../services/sitePath"; @@ -96,14 +97,45 @@ function ExternalIcon() { ); } +// The banner above the sticky nav varies in height, so fit the open menu to the screen space actually left +function fitToViewport(menu: HTMLDivElement | null) { + if (!menu) return; + const fit = () => { + menu.style.maxHeight = `${window.innerHeight - menu.getBoundingClientRect().top}px`; + }; + fit(); + window.addEventListener("resize", fit); + return () => window.removeEventListener("resize", fit); +} + export default function Navbar() { + const pathname = usePathname(); const [isMenuOpen, setIsMenuOpen] = useState(false); + const [menuPathname, setMenuPathname] = useState(pathname); const [openGroup, setOpenGroup] = useState(null); const desktopNav = useRef(null); + const menuButton = useRef(null); const closeMenu = () => setIsMenuOpen(false); const closeGroup = () => setOpenGroup(null); + // Close on any navigation, back/forward included; resetting during render avoids a frame of open menu on the new page + if (menuPathname !== pathname) { + setMenuPathname(pathname); + setIsMenuOpen(false); + } + + useEffect(() => { + if (!isMenuOpen) return; + const closeOnEscape = (event: KeyboardEvent) => { + if (event.key !== "Escape") return; + setIsMenuOpen(false); + menuButton.current?.focus(); + }; + document.addEventListener("keydown", closeOnEscape); + return () => document.removeEventListener("keydown", closeOnEscape); + }, [isMenuOpen]); + useEffect(() => { if (!openGroup) return; // Safari never focuses a clicked button, so blur alone cannot close the panel @@ -127,7 +159,7 @@ export default function Navbar() {