fix(sidebar): check isMobile before collapsible=none; sticky desktop layout
- Swap isMobile and collapsible=none checks: mobile always gets Sheet overlay regardless of collapsible setting. Previously collapsible=none rendered an inline div on mobile, pushing content and preventing close. - collapsible=none desktop path: use sticky top-0 h-svh instead of h-full so the sidebar stays visible while the page scrolls. - Update sidebar-none-mode CSS to use align-items:flex-start which is required for sticky children in a flex container. Root cause: stored sidebarCollapsible=none pref (set via theme customizer) triggered this code path on both mobile and desktop.
This commit is contained in:
+3
-4
@@ -132,10 +132,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix for sidebar "none" mode height issue */
|
/* sidebar-none-mode: sticky layout — sidebar stays visible while page scrolls */
|
||||||
.sidebar-none-mode [data-slot="sidebar"] {
|
.sidebar-none-mode {
|
||||||
height: 100vh !important;
|
align-items: flex-start;
|
||||||
min-height: 100vh !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix for right-side inset variant support */
|
/* Fix for right-side inset variant support */
|
||||||
|
|||||||
@@ -172,24 +172,10 @@ function Sidebar({
|
|||||||
}) {
|
}) {
|
||||||
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
||||||
|
|
||||||
if (collapsible === "none") {
|
// Mobile check must come first — always use Sheet on mobile regardless of collapsible mode
|
||||||
return (
|
|
||||||
<div
|
|
||||||
data-slot="sidebar"
|
|
||||||
className={cn(
|
|
||||||
"bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile) {
|
||||||
return (
|
return (
|
||||||
<Sheet open={openMobile} onOpenChange={setOpenMobile} modal={false} {...props}>
|
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
||||||
<SheetContent
|
<SheetContent
|
||||||
data-sidebar="sidebar"
|
data-sidebar="sidebar"
|
||||||
data-slot="sidebar"
|
data-slot="sidebar"
|
||||||
@@ -212,6 +198,21 @@ function Sidebar({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (collapsible === "none") {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="sidebar"
|
||||||
|
className={cn(
|
||||||
|
"bg-sidebar text-sidebar-foreground sticky top-0 self-start flex h-svh w-(--sidebar-width) flex-col overflow-y-auto",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="group peer text-sidebar-foreground hidden md:block"
|
className="group peer text-sidebar-foreground hidden md:block"
|
||||||
|
|||||||
Reference in New Issue
Block a user