From bfb961ccbe1d136f28338f74eefe1897c60b267b Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Sun, 4 Jan 2026 12:27:51 +0700 Subject: [PATCH] fix: Help page scroll and sidebar positioning - Remove internal overflow (use wp-admin page scroll) - Sidebar sticky under topbar with correct positioning - Standalone mode: top-16 (below 64px header) - WP Admin mode: top-[calc(7rem+32px)] (header+topnav+wp-admin bar) - Uses useApp() to detect mode --- admin-spa/src/routes/Help/index.tsx | 128 ++++++++++++++++------------ 1 file changed, 72 insertions(+), 56 deletions(-) diff --git a/admin-spa/src/routes/Help/index.tsx b/admin-spa/src/routes/Help/index.tsx index e5bbb39..a4ef859 100644 --- a/admin-spa/src/routes/Help/index.tsx +++ b/admin-spa/src/routes/Help/index.tsx @@ -3,6 +3,7 @@ import { useSearchParams } from 'react-router-dom'; import { Book, ChevronRight, FileText, Settings, Layers, Puzzle, Menu, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { cn } from '@/lib/utils'; +import { useApp } from '@/contexts/AppContext'; import DocContent from './DocContent'; import type { DocSection } from './types'; @@ -21,8 +22,22 @@ export default function Help() { const [expandedSections, setExpandedSections] = useState>({}); const [sidebarOpen, setSidebarOpen] = useState(false); + const { isStandalone } = useApp(); + const currentSlug = searchParams.get('doc') || 'getting-started'; + // Calculate sticky top position based on mode + // Standalone/fullscreen mode: top-16 (below 64px header) + // WP Admin mode: top-[calc(7rem+32px)] (header + topnav + wp-admin bar) + const sidebarTopClass = isStandalone + ? 'top-16' + : 'top-[calc(7rem+32px)]'; + + // Height calculation: full height minus header + const sidebarHeightClass = isStandalone + ? 'h-[calc(100vh-64px)]' + : 'h-[calc(100vh-7rem-32px)]'; + // Fetch documentation registry useEffect(() => { const fetchDocs = async () => { @@ -64,32 +79,35 @@ export default function Help() { const selectDoc = (slug: string) => { setSearchParams({ doc: slug }); - setSidebarOpen(false); // Close mobile sidebar + setSidebarOpen(false); }; const isActive = (slug: string) => slug === currentSlug; return ( -
+
{/* Mobile menu button */} - {/* Sidebar */} + {/* Sidebar - sticky, positioned below header */} {/* Backdrop for mobile */} @@ -153,9 +169,9 @@ export default function Help() { /> )} - {/* Main content */} -
-
+ {/* Main content - uses page scroll, not internal overflow */} +
+