代码提交
This commit is contained in:
1 parent
f0ccd6fb09
commit
677faab273
1 file changed
+15
-3
@@ -71,15 +71,27 @@ export function WorkspaceLayout({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarProvider
|
<SidebarProvider
|
||||||
className="h-full w-full overflow-x-hidden [&_[data-slot=sidebar-container]]:left-[var(--page-sidebar-width)]"
|
// 关键:把 workspace 侧栏从「锚定视口(fixed)」改成「锚定本布局容器(absolute)」。
|
||||||
|
// 原 shadcn 原语用 fixed + left:var(--page-sidebar-width) + top:var(--header-height)
|
||||||
|
// 把侧栏钉在视口坐标上 —— 在无界等「DOM 挂主文档、容器不占满整屏」的嵌套场景下,
|
||||||
|
// fixed 会逃逸到整屏左侧、高度锁死为视口高度(即超出父元素 / 高度写死的根因)。
|
||||||
|
//
|
||||||
|
// 改 absolute 后侧栏改以本 wrapper(relative)为定位基准;又因外层 main 已经
|
||||||
|
// pl-[--page-sidebar-width] 让开了页面侧栏、且 main 的 pl 恒等于 --page-sidebar-width,
|
||||||
|
// 故这里 left/top 归零即与原 fixed 视觉位置逐像素一致;高度则跟随容器而非视口。
|
||||||
|
// 作用域仅限本 SidebarProvider 实例(不动全局 ui/sidebar 原语),不影响 artifacts 等其它侧栏。
|
||||||
|
className={[
|
||||||
|
"relative h-full w-full overflow-x-hidden",
|
||||||
|
"[&_[data-slot=sidebar-container]]:absolute",
|
||||||
|
"[&_[data-slot=sidebar-container]]:left-0",
|
||||||
|
"[&_[data-slot=sidebar-container]]:top-0",
|
||||||
|
].join(" ")}
|
||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
"--page-sidebar-width": pageSidebarWidth,
|
"--page-sidebar-width": pageSidebarWidth,
|
||||||
"--header-height": headerHidden ? "0rem" : "4rem",
|
"--header-height": headerHidden ? "0rem" : "4rem",
|
||||||
} as CSSProperties
|
} as CSSProperties
|
||||||
}
|
}
|
||||||
// Keep the fixed workspace sidebar aligned to the outer page sidebar width.
|
|
||||||
// This lets it slide together when the outer sidebar collapses or expands.
|
|
||||||
data-page-sidebar-collapsed={pageSidebarCollapsed}
|
data-page-sidebar-collapsed={pageSidebarCollapsed}
|
||||||
defaultOpen
|
defaultOpen
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user