Measure the iOS touch offset on the device that has it
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Tests / test (push) Canceled after 0s

Press a row on an iPhone and the one above it reacts — but only sometimes, and
only after typing. That is the shape of the keyboard displacement the app already
fights in lib/viewport-guard.js: iOS slides the *visual* viewport inside the layout
one, everything `position:fixed` is painted against the layout viewport, and the
app and the finger disagree until something scrolls. The guard stands down while a
text field has focus on purpose (touching the page there threw the keyboard back
out — issue #242), and that is precisely the window this falls into.

Which correction is right depends on numbers that only exist on the phone:
visualViewport.offsetTop, innerHeight, the scale, whether the body is pinned. So
this adds a readout instead of a guess. Open the app with `vvdebug` anywhere in the
URL, type in a field, tap the row that misbehaves, and read what the viewports were
at the moment of that tap — plus which element the browser believed was under the
finger, which is the other half of the question ("did it hit the row above, or the
row it hit is not where it is drawn?").

It renders nothing without the parameter, and removing it is this file plus one
line in App.jsx.
This commit is contained in:
dsantillan committed 2026-09-21 16:07:23 -04:00
1 parent 903a435af3
commit 0819d03efb
2 files changed
+91

No files matched your search

+3
View File
@@ -38,6 +38,7 @@ import Admin from './views/Admin.jsx'
import CoachChat from './views/CoachChat.jsx'
import CoachIntake from './views/CoachIntake.jsx'
import CoachSetup from './views/CoachSetup.jsx'
import TouchDebug from './components/TouchDebug.jsx'
// last known scrollY per route, so back-navigation can put the page where it was
const scrollPositions = new Map()
@@ -181,6 +182,8 @@ function Shell() {
<Modals />
<Toast />
<TimerFlash />
{/* Renders nothing unless the URL carries `vvdebug` — see the file for what it is for. */}
<TouchDebug />
</>
)
}
+88
View File
@@ -0,0 +1,88 @@
/* Touch diagnostics, for the one bug that cannot be reproduced off a phone.
*
* On iOS the keyboard does not resize the layout viewport: it slides the *visual* viewport inside
* it. Everything `position:fixed` is painted against the layout viewport, so while that gap is
* open the app and the finger disagree — press a row and the one above it reacts. The app already
* carries lib/viewport-guard.js for it, and that module stands down while a text field has focus
* on purpose (touching the page there threw the keyboard back out — issue #242), which is exactly
* the window this falls into.
*
* A fix needs the numbers, and the numbers only exist on the device. Open the app with `vvdebug`
* anywhere in the URL (`…/?vvdebug=1`, `…/#/settings?vvdebug=1`), type in a field, tap the thing
* that misbehaves, and read the panel: it shows what the viewports were at the moment of that tap
* and which element the browser believed was under the finger.
*
* It is deliberately a separate component rather than a branch inside the app: it renders nothing
* at all unless the parameter is there, and deleting this file and its one line in App.jsx is the
* whole removal.
*/
import { useEffect, useRef, useState } from 'react'
const enabled = () => typeof location !== 'undefined' && /[?&#]vvdebug\b/.test(location.href)
const read = () => {
const vv = window.visualViewport
const b = document.body?.style
return {
innerHeight: Math.round(window.innerHeight),
visualHeight: vv ? Math.round(vv.height) : null,
visualTop: vv ? Math.round(vv.offsetTop || 0) : null,
visualPageTop: vv ? Math.round(vv.pageTop || 0) : null,
scrollY: Math.round(window.scrollY || 0),
scale: vv && vv.scale ? Math.round(vv.scale * 100) / 100 : null,
pinned: b?.position === 'fixed' ? (b.top || 'fixed') : 'no',
active: document.activeElement?.tagName || '—',
}
}
export default function TouchDebug() {
const [rows, setRows] = useState([])
const [snap, setSnap] = useState(null)
const box = useRef(null)
useEffect(() => {
if (!enabled()) return
setSnap(read())
const vv = window.visualViewport
const onMove = () => setSnap(read())
// Capture phase, so the reading is the one the browser is about to act on rather than the
// one after React has handled the tap.
const onDown = e => {
const x = Math.round(e.clientX), y = Math.round(e.clientY)
const el = document.elementFromPoint(x, y)
const label = el ? `${el.tagName.toLowerCase()}${el.className ? '.' + String(el.className).split(' ')[0] : ''} "${(el.textContent || '').trim().slice(0, 24)}"` : '—'
const line = `tap ${x},${y} → ${label} · vvTop ${read().visualTop}`
setRows(r => [line, ...r].slice(0, 6))
}
window.addEventListener('pointerdown', onDown, true)
window.addEventListener('touchstart', onDown, true)
vv?.addEventListener('resize', onMove)
vv?.addEventListener('scroll', onMove)
window.addEventListener('scroll', onMove)
window.addEventListener('resize', onMove)
const tick = setInterval(onMove, 500)
return () => {
window.removeEventListener('pointerdown', onDown, true)
window.removeEventListener('touchstart', onDown, true)
vv?.removeEventListener('resize', onMove)
vv?.removeEventListener('scroll', onMove)
window.removeEventListener('scroll', onMove)
window.removeEventListener('resize', onMove)
clearInterval(tick)
}
}, [])
if (!enabled() || !snap) return null
const line = Object.entries(snap).map(([k, v]) => `${k} ${v}`).join(' ')
return <div ref={box} style={{
position: 'fixed', left: 0, right: 0, top: 0, zIndex: 9999,
background: 'rgba(0,0,0,.86)', color: '#d7ff6b', font: '11px/1.45 ui-monospace,monospace',
padding: '6px 8px', pointerEvents: 'none', whiteSpace: 'pre-wrap', wordBreak: 'break-word',
}}>
{'VVDEBUG ' + line}
{rows.map((r, i) => <div key={i} style={{ opacity: 1 - i * 0.15 }}>{r}</div>)}
</div>
}