From f242da8429e954270d7e22ef9d4201f17e8670b9 Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Sun, 8 Nov 2026 20:55:17 +0100 Subject: [PATCH] Admin-layout: alleen de inhoud scrolt, de zijbalk blijft staan De schil was min-h-svh, dus zodra de inhoud iets hoger was dan het scherm scrolde het hele document en de zijbalk mee. Nu is de schil precies een scherm hoog zonder eigen scroll en scrolt alleen het inhoudsgebied; het menu in de zijbalk scrolt zelf op een heel laag scherm. Co-Authored-By: Claude Sonnet 5.5 --- .../src/components/layout/AppLayout.test.tsx | 33 +++++++++++++++++++ frontend/src/components/layout/AppLayout.tsx | 11 ++++--- frontend/src/components/layout/Sidebar.tsx | 2 +- 3 files changed, 41 insertions(+), 5 deletions(-) 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 = {}) { )}
-