From 69fd4a83444da92601d716b13c78ec61a26e4b4e Mon Sep 17 00:00:00 2001 From: Duarte Santos Date: Thu, 17 Sep 2026 11:32:31 +0200 Subject: [PATCH] List view opens at the current exercise instead of the top of the session (#224) --- frontend/src/index.css | 2 ++ frontend/src/views/Workout.jsx | 12 +++++++++++- frontend/src/views/Workout.test.jsx | 7 +++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/frontend/src/index.css b/frontend/src/index.css index 12a1643..c35aa7d 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -1149,6 +1149,8 @@ body.chips-dragging *{cursor:inherit} border-radius:var(--r-lg);padding:14px 14px 4px; background:var(--surface-2); } +/* scrolled to when the list opens (#224): clear the sticky header above it */ +.wl-unit{scroll-margin-top:calc(var(--sat) + 96px)} .wl-unit.cur{box-shadow:inset 0 0 0 1.5px var(--acc-line)} .wl-hd{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px} @media (max-width:400px){ diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index 8e772d0..89a474b 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -578,6 +578,16 @@ function ActiveWorkout() { const el = (setIdx >= 0 && setRefs.current.get(entry)?.get(setIdx)) || exRefs.current.get(entry) if (el && typeof el.scrollIntoView === 'function') el.scrollIntoView({ behavior: 'smooth', block: 'center' }) }, [cur, isSuperset, listMode, A.entries.length]) + // The list opens at the exercise you are on, not at the top of the session (issue #224): you + // switch to it mid-workout to look at what comes before and after. Only on the way in — once + // the list is open, "current" moves because you tick rows in it, and a list that scrolls + // itself under your thumb is worse than one that stays put. + const listRef = useRef(null) + useEffect(() => { + if (!listMode) return + const el = listRef.current?.querySelector('.wl-unit.cur') + if (el && typeof el.scrollIntoView === 'function') el.scrollIntoView({ block: 'start' }) + }, [listMode]) const total = setUnitsTotal(A.entries) const done = setsDoneActive(A) @@ -946,7 +956,7 @@ function ActiveWorkout() { {A.backfill &&
{t('Logging a past workout — no rest timers.')}
} {A.entries.length ? (listMode ? ( -
+
{units.map((u, ui) => { const multi = u.length > 1 const isCur = u.includes(cur) diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx index 5409de4..7a737e3 100644 --- a/frontend/src/views/Workout.test.jsx +++ b/frontend/src/views/Workout.test.jsx @@ -1012,6 +1012,13 @@ describe('workout list view', () => { const units = () => [...container.querySelectorAll('.wl-unit')] const focusButton = unit => [...unit.querySelectorAll('button')].find(b => b.textContent.trim() === 'Set current') + it('opens at the current exercise instead of the top of the session (#224)', async () => { + await mount([exercise('plain-bench', [true]), exercise('plain-row', [true]), exercise('plain-curl', [false])], 2, { workoutView: 'list' }) + expect(mocks.scrollCalls.length).toBe(1) + expect(mocks.scrollCalls[0].node).toBe(units()[2]) + expect(mocks.scrollCalls[0].node.classList.contains('cur')).toBe(true) + }) + it('stacks every exercise, labels each unit, and hides card navigation', async () => { await mount([exercise('plain-bench', [false, false]), exercise('plain-row', [false])], 0, { workoutView: 'list' })