Skip to content

Commit df3e1ff

Browse files
committed
fix sidebar nav scroll behavior
1 parent e2831ad commit df3e1ff

1 file changed

Lines changed: 9 additions & 26 deletions

File tree

apps/web/ui/layout/sidebar/sidebar-nav.tsx

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,32 +182,17 @@ function SidebarAreasPanel<T extends Record<any, any>>({
182182
const { scrollProgress, updateScrollProgress } = useScrollProgress(scrollRef);
183183
const showNews = currentArea && areas[currentArea]?.(data).showNews;
184184

185-
const hasOverflow = useMemo(() => {
186-
if (!currentArea) return false;
187-
const { content } = areas[currentArea](data);
188-
// assume custom ReactNode elements always overflow
189-
if (isValidElement(content)) return true;
190-
191-
const totalItems = Array.isArray(content)
192-
? content.flatMap((c) => c.items).length
193-
: 0;
194-
return totalItems > 10;
195-
}, [currentArea, areas, data]);
196-
197185
return (
198186
<div className="flex h-full w-[calc(var(--sidebar-areas-width)-0.5rem)] flex-col rounded-xl bg-neutral-100">
199187
{/* Scrollable content with gradient overlay */}
200188
<div className="relative min-h-0 flex-1 overflow-hidden">
201189
<div
202190
ref={scrollRef}
203191
onScroll={updateScrollProgress}
204-
className={cn(
205-
"scrollbar-hide h-full overflow-x-hidden rounded-xl",
206-
hasOverflow ? "overflow-y-auto" : "overflow-hidden",
207-
)}
192+
className="scrollbar-hide max-h-full overflow-y-auto overflow-x-hidden rounded-xl"
208193
>
209194
<div className="relative flex flex-col p-3 text-neutral-500">
210-
<div className="relative w-full grow">
195+
<div className="relative w-full overflow-hidden">
211196
{Object.entries(areas).map(([area, areaConfig]) => {
212197
const { title, backHref, content, direction } =
213198
areaConfig(data);
@@ -268,12 +253,10 @@ function SidebarAreasPanel<T extends Record<any, any>>({
268253
</div>
269254
</div>
270255
{/* Bottom scroll fade - shows when content overflows */}
271-
{hasOverflow && (
272-
<div
273-
className="pointer-events-none absolute bottom-0 left-0 z-10 h-16 w-full rounded-b-lg bg-gradient-to-t from-neutral-100 to-transparent"
274-
style={{ opacity: 1 - Math.pow(scrollProgress, 2) }}
275-
/>
276-
)}
256+
<div
257+
className="pointer-events-none absolute bottom-0 left-0 z-10 h-16 w-full rounded-b-lg bg-gradient-to-t from-neutral-100 to-transparent"
258+
style={{ opacity: 1 - Math.pow(scrollProgress, 2) }}
259+
/>
277260
</div>
278261

279262
{/* Fixed bottom sections - always visible */}
@@ -509,11 +492,11 @@ export function Area({
509492
return (
510493
<div
511494
className={cn(
512-
"left-0 top-0 flex size-full flex-col md:transition-[opacity,transform] md:duration-300",
495+
"left-0 top-0 flex flex-col md:transition-[opacity,transform] md:duration-300",
513496
visible
514-
? "opacity-1 relative"
497+
? "relative w-full opacity-100"
515498
: cn(
516-
"pointer-events-none absolute opacity-0",
499+
"pointer-events-none absolute inset-0 overflow-hidden opacity-0",
517500
direction === "left" ? "-translate-x-full" : "translate-x-full",
518501
),
519502
)}

0 commit comments

Comments
 (0)