Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shell-frame-stays-put.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions packages/core/src/components/sidebar/content-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/components/sidebar/primitives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,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}
Expand Down
29 changes: 29 additions & 0 deletions packages/core/src/components/sidebar/sidebar-layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,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);
Expand Down
Loading