diff --git a/frontend/src/components/layout/AppLayout.test.tsx b/frontend/src/components/layout/AppLayout.test.tsx index f749cd8..7a7098b 100644 --- a/frontend/src/components/layout/AppLayout.test.tsx +++ b/frontend/src/components/layout/AppLayout.test.tsx @@ -27,6 +27,39 @@ describe('AppLayout desktop', () => { }); }); +describe('AppLayout scrolling', () => { + // jsdom has no layout engine, so these assert the classes that make the browser behave: a one-screen-high + // shell that does not scroll itself, with the content area as the only scroll container. + it('is one screen high and does not scroll as a whole, so the sidebar stays put', async () => { + mockAuthenticated(); + renderApp('/dashboard'); + const shell = await screen.findByTestId('app-shell'); + + expect(shell).toHaveClass('h-svh', 'overflow-hidden'); + expect(shell).not.toHaveClass('min-h-svh'); + }); + + it('scrolls only the content area', async () => { + mockAuthenticated(); + renderApp('/dashboard'); + await screen.findByTestId('app-sidebar'); + + expect(screen.getByTestId('app-main')).toHaveClass('overflow-y-auto'); + expect(screen.getByTestId('app-sidebar-column')).toHaveClass('h-full'); + // The sidebar's own menu scrolls inside it on a very short screen, never the page. + expect(screen.getByTestId('app-sidebar').querySelector('nav')).toHaveClass('overflow-y-auto'); + }); + + it('applies on every page of the shell, for example the settings page', async () => { + mockAuthenticated(); + renderApp('/settings'); + await screen.findByTestId('settings-title', {}, { timeout: 10000 }); + + expect(screen.getByTestId('app-shell')).toHaveClass('h-svh', 'overflow-hidden'); + expect(screen.getByTestId('app-main')).toContainElement(screen.getByTestId('settings-title')); + }); +}); + describe('AppLayout mobile menu', () => { it('opens sidebar overlay when hamburger is clicked', async () => { mockAuthenticated(); diff --git a/frontend/src/components/layout/AppLayout.tsx b/frontend/src/components/layout/AppLayout.tsx index a417c6e..74bea9a 100644 --- a/frontend/src/components/layout/AppLayout.tsx +++ b/frontend/src/components/layout/AppLayout.tsx @@ -33,14 +33,17 @@ export function AppLayout() { } return ( -
-
+ // The shell is exactly one screen high and does not scroll itself: the sidebar stays where it is and + // only the content area scrolls. (With min-h-svh the whole document scrolled as soon as the content + // was a little taller than the screen, and the sidebar scrolled away with it.) +
+
{isMenuOpen && setIsMenuOpen(false)} />} -
+
setIsMenuOpen(true)} /> -
+
diff --git a/frontend/src/components/layout/Sidebar.tsx b/frontend/src/components/layout/Sidebar.tsx index 56f32dc..37f72bf 100644 --- a/frontend/src/components/layout/Sidebar.tsx +++ b/frontend/src/components/layout/Sidebar.tsx @@ -81,7 +81,7 @@ export function Sidebar({ onClose }: SidebarProps = {}) { )}
-