ReviewOS

also looking at this

loghqorg/loghq

fix(ui): bound the mobile menu to the visible viewport

#5
Merged glennmichael123 wants to merge fix/mobile-nav into main
2 files +24 -0
tests/unit/mobile-layout.test.tsadded+22-0
Changes to tests/unit/mobile-layout.test.ts
@@ -0,0 +1,22 @@
1import { describe, expect, test } from 'bun:test'
2import { readFileSync } from 'node:fs'
3import { join } from 'node:path'
4
5const ROOT = join(import.meta.dir, '../..')
6const marketing = readFileSync(join(ROOT, 'public/marketing.css'), 'utf8')
7
8// The phone menu lists every marketing destination in one column, which is
9// taller than an 812px viewport. The panel has to scroll inside the viewport
10// and the page behind it has to stay put, or the last links are unreachable.
11describe('mobile layout contracts', () => {
12 test('marketing menu is bounded by the visible mobile viewport', () => {
13 const panel = marketing.match(/\.nav-menu-panel\s*\{[^}]*\}/)?.[0] ?? ''
14 expect(panel).toContain('max-height: calc(100dvh - 92px)')
15 expect(panel).toContain('overflow-y: auto')
16 expect(panel).toContain('overscroll-behavior: contain')
17 })
18
19 test('opening the marketing menu locks the page behind it', () => {
20 expect(marketing).toContain('body:has(.nav-menu[open]) { overflow: hidden; }')
21 })
22})