🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(layout): stop drawer content from scrolling the whole page (#16080)
Nikita Kabardinee04802beb52
diff --git a/web/src/__e2e__/app-shell-overflow.spec.ts b/web/src/__e2e__/app-shell-overflow.spec.tsnew file mode 100644index 0000000000..37bde5b9f4--- /dev/null+++ b/web/src/__e2e__/app-shell-overflow.spec.ts@@ -0,0 +1,54 @@+import { test, expect, type Page } from "@playwright/test";++/**+ * The app shell is fully height- and width-constrained: page content scrolls+ * inside it, and the document itself must never scroll. These assertions need+ * real layout, so they live here rather than in a jsdom client test.+ */++const SHORT_VIEWPORT = { width: 1190, height: 560 };++async function signIn(page: Page) {+ await page.goto("/auth/sign-in");+ await page.fill('input[name="email"]', "[email protected]");+ await page.fill('input[type="password"]', "password");+ await page.click('button[data-testid="submit-email-password-sign-in-form"]');+ await expect(page).toHaveURL("/");+}++/** Document overflow in CSS px, per axis. */+function documentOverflow(page: Page) {+ return page.evaluate(() => {+ const de = document.documentElement;+ return {+ y: de.scrollHeight - de.clientHeight,+ x: de.scrollWidth - de.clientWidth,+ };+ });+}++test("a right drawer's absolutely-positioned content does not scroll the document", async ({+ page,+}) => {+ await page.setViewportSize(SHORT_VIEWPORT);+ await signIn(page);+ await page.getByRole("button", { name: "Support" }).click();+ const drawerBody = page.locator("#secondary div.overflow-y-auto").first();+ await expect(drawerBody).toBeVisible();++ // Tailwind's `sr-only` box, appended below the fold of the drawer's own+ // scroll area. With no positioned ancestor inside the drawer it resolves its+ // containing block against the app shell, escapes the drawer's clip and+ // grows the document instead of scrolling inside the drawer.+ await drawerBody.evaluate((body) => {+ const probe = document.createElement("span");+ probe.dataset.testid = "overflow-probe";+ probe.style.cssText =+ "position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)";+ const spacer = document.createElement("div");+ spacer.style.height = "1200px";+ body.append(spacer, probe);+ });++ expect(await documentOverflow(page)).toEqual({ y: 0, x: 0 });+});diff --git a/web/src/components/ui/resizable-split-layout.tsx b/web/src/components/ui/resizable-split-layout.tsxindex 91f4ae39da..3dcaf65e00 100644--- a/web/src/components/ui/resizable-split-layout.tsx+++ b/web/src/components/ui/resizable-split-layout.tsx@@ -7,6 +7,7 @@ import {useDefaultLayout,usePanelRef,} from "@/src/components/ui/resizable";+import { cn } from "@/src/utils/tailwind";interface ResizableSplitLayoutProps {primaryContent: ReactNode;@@ -130,13 +131,16 @@ export function ResizableSplitLayout({? handleSecondaryResizeCallback: undefined;+ // `relative` mirrors the primary panel's wrapper below: without a containing+ // block here, absolutely-positioned secondary content (Tailwind's `sr-only`+ // among it) resolves against the app shell, escapes this panel's scroll clip+ // and grows the document instead.// In rail mode the collapsed panel stays visible (the caller renders a rail// in it) and keeps its handle so it can be dragged back open.- const secondaryPanelClassName = hasCollapsedRail- ? undefined- : open- ? "visible"- : "invisible";+ const secondaryPanelClassName = cn(+ "relative",+ !hasCollapsedRail && (open ? "visible" : "invisible"),+ );const showSecondaryHandle = showHandle && (open || hasCollapsedRail);return (