fix: prevent sidebar wheel from blocking tree library scrolling
This commit is contained in:
@@ -112,8 +112,27 @@ export function Sidebar() {
|
||||
}
|
||||
}
|
||||
|
||||
const handleSidebarWheel = (e: React.WheelEvent<HTMLElement>) => {
|
||||
const sidebar = e.currentTarget
|
||||
const canSidebarScroll = sidebar.scrollHeight > sidebar.clientHeight
|
||||
const atTop = sidebar.scrollTop <= 0
|
||||
const atBottom = sidebar.scrollTop + sidebar.clientHeight >= sidebar.scrollHeight - 1
|
||||
|
||||
// If sidebar can't consume wheel movement, forward it to main content scroller.
|
||||
if (!canSidebarScroll || (e.deltaY < 0 && atTop) || (e.deltaY > 0 && atBottom)) {
|
||||
const main = document.querySelector('.main-content') as HTMLElement | null
|
||||
if (main) {
|
||||
main.scrollTop += e.deltaY
|
||||
e.preventDefault()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<nav className="sidebar flex flex-col border-r border-border bg-[hsl(var(--sidebar-bg))]">
|
||||
<nav
|
||||
className="sidebar flex flex-col border-r border-border bg-[hsl(var(--sidebar-bg))]"
|
||||
onWheel={handleSidebarWheel}
|
||||
>
|
||||
{sidebarCollapsed ? (
|
||||
<>
|
||||
{/* Collapsed: icon-only nav */}
|
||||
|
||||
Reference in New Issue
Block a user