ReviewOS

also looking at this

stacks/commshq

fix(auth): keep sign-in inputs at 16px so iOS does not zoom on focus

#8
Merged glennmichael123 wants to merge fix/auth-input-zoom into main
2 files +24 -2
tests/Unit/MobileLayout.test.tsadded+22-0
Changes to tests/Unit/MobileLayout.test.ts
@@ -0,0 +1,22 @@
1import { describe, expect, it } from 'bun:test'
2import { readFileSync } from 'node:fs'
3import { join } from 'node:path'
4
5const auth = readFileSync(join(import.meta.dir, '../../resources/views/layouts/auth.stx'), 'utf8')
6
7// iOS Safari zooms the page when a focused input's font-size is under 16px,
8// and leaves it zoomed and scrolled sideways afterwards. The sign-in and
9// sign-up forms are the first thing a phone user types into.
10describe('mobile layout contracts', () => {
11 it('keeps auth inputs at 16px so iOS does not zoom on focus', () => {
12 const field = auth.match(/\.field\s*\{[^}]*\}/)?.[0] ?? ''
13 const size = Number(field.match(/font:\s*\d+\s+(\d+(?:\.\d+)?)px/)?.[1])
14 expect(size).toBeGreaterThanOrEqual(16)
15 })
16
17 it('leaves pinch-zoom available on the auth pages', () => {
18 const viewport = auth.match(/<meta name="viewport" content="([^"]+)"/)?.[1] ?? ''
19 expect(viewport).toContain('width=device-width')
20 expect(viewport).not.toMatch(/user-scalable=no|maximum-scale=1(?![.\d])/)
21 })
22})