Skip to content

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.

List view opens at the current exercise instead of the top of the session (#224)

Duarte Santos69fd4a83444d
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 12a1643b4..c35aa7d56 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 8e772d080..89a474b90 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 && <div className="muted small" style={{ marginBottom: 8 }}>{t('Logging a past workout — no rest timers.')}</div>}
{A.entries.length ? (listMode ? (
- <div className="workout-list" data-testid="workout-list">
+ <div className="workout-list" data-testid="workout-list" ref={listRef}>
{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 5409de4d7..7a737e387 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' })