From 64b0746ff1c658878110ae2ae87f2b3e02ab5294 Mon Sep 17 00:00:00 2001 From: itsprade Date: Tue, 10 Nov 2026 18:53:56 +0530 Subject: [PATCH] fix(sidebar): keep the shell frame from scrolling Absolutely positioned descendants of the content area, such as the hidden inputs Select and Combobox render, were positioned against SidebarInset and stretched the sidebar wrapper far past the window. The wrapper is overflow-hidden, which still allows anchor jumps, scrollIntoView and focus to scroll it, so the header and sidebar shifted out of place. - The content scroll container is now `position: relative`, so those descendants scroll with the content. - The wrapper uses `overflow: clip`, which cannot be scrolled at all. Co-Authored-By: Claude Opus 5.5 --- .changeset/shell-frame-stays-put.md | 5 ++++ .../components/sidebar/content-container.tsx | 4 +++ .../src/components/sidebar/primitives.tsx | 6 ++-- .../sidebar/sidebar-layout.test.tsx | 29 +++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .changeset/shell-frame-stays-put.md diff --git a/.changeset/shell-frame-stays-put.md b/.changeset/shell-frame-stays-put.md new file mode 100644 index 000000000..dc84aa7bf --- /dev/null +++ b/.changeset/shell-frame-stays-put.md @@ -0,0 +1,5 @@ +--- +"@tailor-platform/app-shell": patch +--- + +The shell no longer shifts when a page jumps to an anchor, calls `scrollIntoView` or focuses a field below the fold. On long forms, the hidden inputs inside `Select` and `Combobox` made the shell's outer frame taller than the window, and those jumps scrolled the frame itself, pushing the header out of view. The content scroll area now contains those inputs, and the frame can no longer be scrolled. diff --git a/packages/core/src/components/sidebar/content-container.tsx b/packages/core/src/components/sidebar/content-container.tsx index ac965e329..c83113784 100644 --- a/packages/core/src/components/sidebar/content-container.tsx +++ b/packages/core/src/components/sidebar/content-container.tsx @@ -67,6 +67,10 @@ export const ContentContainer = ({ header, className, children }: ContentContain data-appshell-scroll-container="" className={cn( "astw:flex astw:flex-col astw:gap-4 astw:flex-1 astw:min-h-0 astw:overflow-y-auto", + // The positioning box for absolutely positioned descendants (such + // as the hidden inputs Select and Combobox render), so they scroll + // with the content instead of stretching the shell frame. + "astw:relative", // Full-bleed: break out of SidebarInset's right padding so the // scrollbar sits at the window edge, then restore the padding // inside so content stays aligned with the header. Mirrors diff --git a/packages/core/src/components/sidebar/primitives.tsx b/packages/core/src/components/sidebar/primitives.tsx index 7bfb2f253..f02de56a7 100644 --- a/packages/core/src/components/sidebar/primitives.tsx +++ b/packages/core/src/components/sidebar/primitives.tsx @@ -172,8 +172,10 @@ function SidebarProvider({ className={cn( // h-svh (not min-h-svh): the shell is viewport-bounded so scrolling // happens in the content area (or inside components like DataTable), - // never on the document itself. - "astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:h-svh astw:w-full astw:overflow-hidden", + // never on the document itself. `overflow-clip` rather than + // `hidden`: a hidden box can still be scrolled by anchor jumps, + // scrollIntoView and focus, which would shift the whole shell. + "astw:group/sidebar-wrapper astw:has-data-[variant=inset]:bg-sidebar astw:flex astw:h-svh astw:w-full astw:overflow-clip", className, )} {...props} diff --git a/packages/core/src/components/sidebar/sidebar-layout.test.tsx b/packages/core/src/components/sidebar/sidebar-layout.test.tsx index 672dfdc2a..13b7385bd 100644 --- a/packages/core/src/components/sidebar/sidebar-layout.test.tsx +++ b/packages/core/src/components/sidebar/sidebar-layout.test.tsx @@ -263,6 +263,35 @@ describe("SidebarLayout", () => { }); }); + describe("scroll containment", () => { + // Anchor jumps, scrollIntoView and focus scroll every scrollable ancestor. + // An `overflow: hidden` frame still counts, so the whole shell shifted up. + it("clips the frame so it can't be scrolled", async () => { + renderSidebarLayout(); + + await waitFor(() => { + expect(document.querySelector('[data-slot="sidebar-wrapper"]')).not.toBeNull(); + }); + + const classes = document.querySelector('[data-slot="sidebar-wrapper"]')?.className.split(" "); + expect(classes).toContain("astw:overflow-clip"); + expect(classes).not.toContain("astw:overflow-hidden"); + }); + + it("positions absolute content against the content scroller, not the frame", async () => { + renderSidebarLayout(); + + await waitFor(() => { + expect(document.querySelector("[data-appshell-scroll-container]")).not.toBeNull(); + }); + + // Select and Combobox render absolutely positioned hidden inputs; they + // must scroll with the content instead of stretching the frame. + const scroller = document.querySelector("[data-appshell-scroll-container]"); + expect(scroller?.className.split(" ")).toContain("astw:relative"); + }); + }); + describe("namespace", () => { it("exposes DefaultSidebar and DefaultHeader on SidebarLayout", () => { expect(SidebarLayout.DefaultSidebar).toBe(DefaultSidebar);