iOS: the page no longer stays displaced after the keyboard goes away (tab bar mid-screen, first rows under the status bar)

Safari scrolls the page to show a focused field even with the body pinned under a sheet, and
does not always undo it when the keyboard closes — most often after "+" in the exercise picker,
where the sheet stays open and the sheet's own restore never runs. A window-level guard now
realigns the viewports once the keyboard has gone (and again after its dismiss animation), and
the sheet restore repeats itself after that animation too.
This commit is contained in:
Duarte Santos committed 2026-09-06 17:36:45 +02:00
1 parent 684b0054ad
commit 5c2005e81f
4 files changed
+153

No files matched your search

+3
View File
@@ -8,6 +8,7 @@ import { setLang, useLang } from './lib/i18n.js'
import { setNav } from './lib/nav.js'
import { initBackButton } from './lib/back.js'
import { useWakeLock } from './lib/wakelock.js'
import { installViewportGuard } from './lib/viewport-guard.js'
import { startFlow } from './sheets.jsx'
import Icon from './components/Icon.jsx'
import TabBar from './components/TabBar.jsx'
@@ -77,6 +78,8 @@ function Shell() {
// The position is recorded from scroll events rather than read at route
// change, because by then a shorter page may already have clamped it.
const pathRef = useRef(loc.pathname)
// iOS leaves the page displaced after the keyboard goes away (see lib/viewport-guard.js).
useEffect(() => installViewportGuard(), [])
useEffect(() => {
const onScroll = () => {
// Modals pins the body while a sheet is open; scrollY is 0 then, not a position.