Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
sheets: un-pin the page in the sheet's own commit, and ignore its history pop
Boris 'B' Kurktchiev71e16038b10c
diff --git a/frontend/src/components/Modals.jsx b/frontend/src/components/Modals.jsxindex 39156cd9c..64279d902 100644--- a/frontend/src/components/Modals.jsx+++ b/frontend/src/components/Modals.jsx@@ -1,4 +1,4 @@-import { useEffect, useRef } from 'react'+import { useEffect, useLayoutEffect, useRef } from 'react'import { useUI } from '../store/useUI.js'import { keyboardOpen } from '../lib/viewport-guard.js'@@ -163,7 +163,11 @@ export default function Modals() {window.addEventListener('keydown', onKey)return () => window.removeEventListener('keydown', onKey)}, [sheets.length])- useEffect(() => {+ // A layout effect, not a passive one: the pin and, above all, the un-pin plus the scroll+ // restore have to land in the same frame as the sheet's own mount/unmount. Run after paint,+ // iOS showed a frame with the body un-pinned at scroll 0 — the page "jumped down and back" on+ // every RIR pick, which closes the sheet and starts a rest in one tap (2026-09-18).+ useLayoutEffect(() => {if (!sheets.length) return// A text field on the page behind (a set's weight, the Library search) keeps focus when a// button opens a sheet — WebKit does not blur on button taps — and its keyboard then@@ -177,6 +181,9 @@ export default function Modals() {return () => {b.position = b.top = b.left = b.right = b.width = ''window.scrollTo(0, y)+ // iOS scrolls asynchronously; a restore issued in the same task as the un-pin can be applied+ // a frame late or against the still-short layout. Say it once more on the next frame.+ if (typeof window.requestAnimationFrame === 'function') window.requestAnimationFrame(() => { if (document.body.style.position !== 'fixed') window.scrollTo(0, y) })// If the sheet closed with the keyboard still up (tap "+" in the picker, then finish),// iOS scrolls the page again while the keyboard dismisses — after the line above ran.// Ask once more when that animation is over. The window-level guard indiff --git a/frontend/src/components/Modals.test.jsx b/frontend/src/components/Modals.test.jsxindex 3bdb4f673..c6466ad92 100644--- a/frontend/src/components/Modals.test.jsx+++ b/frontend/src/components/Modals.test.jsx@@ -327,3 +327,30 @@ describe('Modals scroll restore on close', () => {vi.useRealTimers()})})++// The page behind a sheet is pinned (body fixed, shifted by the scroll position) and put back+// where it was when the sheet goes — in the same commit, so there is no frame at scroll 0.+describe('pinning the page behind a sheet', () => {+ it('pins on open with the scroll position folded in, and restores it on close, three times over', async () => {+ vi.useFakeTimers()+ // the sheet closes with the keyboard still up, so the 350 ms restore is armed too (QA C1)+ dom.innerHeight = 800+ dom.visualViewport = { height: 460 }+ Object.defineProperty(dom, 'scrollY', { configurable: true, value: 343 })+ const rafs = []+ dom.requestAnimationFrame = fn => { rafs.push(fn); return rafs.length }+ await setSheets([sheet('a')])+ expect(document.body.style.position).toBe('fixed')+ expect(document.body.style.top).toBe('-343px')+ expect(dom.scrollTo).not.toHaveBeenCalled()+ await setSheets([])+ expect(document.body.style.position).toBe('')+ expect(dom.scrollTo).toHaveBeenCalledTimes(1) // at once, in the same commit+ expect(dom.scrollTo).toHaveBeenCalledWith(0, 343)+ rafs.forEach(fn => fn())+ expect(dom.scrollTo).toHaveBeenCalledTimes(2) // again on the next frame (iOS scrolls asynchronously)+ vi.advanceTimersByTime(400)+ expect(dom.scrollTo).toHaveBeenCalledTimes(3) // and after the keyboard's dismiss animation+ vi.useRealTimers()+ })+})