ReviewOS

also looking at this

stacks/commshq

fix(ui): keep the phone menu inside the visible viewport

#9
Merged glennmichael123 wants to merge fix/mobile-nav-dvh into main
2 files +16 -2
tests/Unit/MobileLayout.test.tsmodified+11-0
Changes to tests/Unit/MobileLayout.test.ts
@@ -3,6 +3,7 @@ import { readFileSync } from 'node:fs'
33import { join } from 'node:path'
44
55const auth = readFileSync(join(import.meta.dir, '../../resources/views/layouts/auth.stx'), 'utf8')
6const nav = readFileSync(join(import.meta.dir, '../../resources/components/CommsHQ/MarketingNavigation.stx'), 'utf8')
67
78// iOS Safari zooms the page when a focused input's font-size is under 16px,
89// and leaves it zoomed and scrolled sideways afterwards. The sign-in and
@@ -19,4 +20,14 @@ describe('mobile layout contracts', () => {
1920 expect(viewport).toContain('width=device-width')
2021 expect(viewport).not.toMatch(/user-scalable=no|maximum-scale=1(?![.\d])/)
2122 })
23
24 // 100vh is the largest the viewport ever gets on iOS, so a panel capped by it
25 // runs under the browser's bottom bar; 100dvh tracks the visible height.
26 it('bounds the phone menu by the visible viewport and locks the page behind it', () => {
27 const panel = nav.match(/<details class="[^"]*mobile-menu[^"]*">[\s\S]*?<div class="([^"]*)"/)?.[1] ?? ''
28 expect(panel).toContain('max-h-[calc(100dvh-6rem)]')
29 expect(panel).not.toContain('100vh')
30 expect(panel).toContain('overscroll-contain')
31 expect(nav).toContain('body:has(.mobile-menu[open]) { overflow: hidden; }')
32 })
2233})