Skip to content

Commit 9681fcc

Browse files
Simplify sidebar positioning to prevent bouncing
Removed dynamic fixed/sticky toggle that caused layout shifts. Now uses pure CSS sticky positioning for a stable, bounce-free sidebar. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 62b058d commit 9681fcc

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

web/src/app/docs/layout.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,8 @@ export default function DocsLayout({
1717
const [open, setOpen] = useState(false)
1818
const [showTopFade, setShowTopFade] = useState(false)
1919
const [showBottomFade, setShowBottomFade] = useState(false)
20-
const [isFixed, setIsFixed] = useState(false)
2120
const sidebarRef = useRef<HTMLDivElement>(null)
2221

23-
// Track scroll position to determine if sidebar should be fixed
24-
useEffect(() => {
25-
const handleScroll = () => {
26-
// The header with logo is approximately 72px tall (p-4 = 16px top/bottom + content height)
27-
// Fix the sidebar when the user scrolls past the header
28-
const shouldBeFixed = window.scrollY > 72
29-
if (shouldBeFixed !== isFixed) {
30-
setIsFixed(shouldBeFixed)
31-
}
32-
}
33-
34-
window.addEventListener('scroll', handleScroll, { passive: true })
35-
return () => window.removeEventListener('scroll', handleScroll)
36-
}, [isFixed])
37-
3822
// Handle sidebar scroll for dynamic fade effects
3923
useEffect(() => {
4024
const sidebarElement = sidebarRef.current
@@ -60,11 +44,7 @@ export default function DocsLayout({
6044
<div className="pt-8">
6145
<div className="container flex md:space-x-8 overflow-x-hidden">
6246
<div className="hidden lg:block w-64 shrink-0">
63-
<div
64-
className={`w-64 z-40 transition-all duration-200 ease-in-out ${
65-
isFixed ? 'fixed top-4' : 'sticky top-4'
66-
} h-[calc(100vh-2rem)]`}
67-
>
47+
<div className="w-64 sticky top-4 h-[calc(100vh-2rem)] z-40">
6848
{/* Dynamic gradient fade indicators */}
6949
{showTopFade && (
7050
<div className="absolute top-0 left-0 right-0 h-6 bg-gradient-to-b from-background to-transparent pointer-events-none z-10 rounded-t-lg transition-opacity duration-200" />

0 commit comments

Comments
 (0)