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.

fix(workout): list/compact superset scroll lands on the next member's title

Sebastian Ga7c44ccf664c
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 68cea9523..f4efcf1db 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1855,7 +1855,7 @@ body.no-tabbar.resting #toast{bottom:calc(100px + var(--sab))}
own row (Workout.jsx), not the unit: the row needs the same clearance under the sticky header,
since scroll-margin does not inherit from the .wl-unit around it. Scoped to the list so Cards,
which has no pinned header, is untouched. */
-.workout-list .setrow,.workout-list .setrow-side{scroll-margin-top:calc(var(--whdr-h, var(--sat) + var(--conn) + 80px) + 16px)}
+.workout-list .ss-ex,.workout-list .setrow,.workout-list .setrow-side{scroll-margin-top:calc(var(--whdr-h, var(--sat) + var(--conn) + 80px) + 16px)}
.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}
.wl-summary{display:grid;gap:8px;padding-bottom:10px}
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 2b34fbd1c..d7a0c209e 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -1097,14 +1097,20 @@ function ActiveWorkout() {
return afterScrollRestore(() => {
const { entries, cur: at } = shown.current
const entry = entries[at]
+ // Cards centres the actionable set row so a tall first block does not push it off; the list
+ // has the whole session stacked under a pinned header, so it brings the next member's
+ // exercise block (its name first) up under the header, not the set field — you want to see
+ // which exercise you are on, then the row. Fall back to the row/block the other way round.
const firstIncomplete = entry?.sets.findIndex(s => !s.done) ?? -1
const setIdx = firstIncomplete >= 0 ? firstIncomplete : (entry?.sets.length ?? 0) - 1
- const el = (setIdx >= 0 && setRefs.current.get(entry)?.get(setIdx)) || exRefs.current.get(entry)
+ const row = setIdx >= 0 && setRefs.current.get(entry)?.get(setIdx)
+ const block = exRefs.current.get(entry)
+ const el = listMode ? (block || row) : (row || block)
if (!el || typeof el.scrollIntoView !== 'function') return
if (!moved && rowOnScreen(el)) return
- // In the list the header is pinned over the page: land the row below it (block:'start',
- // fed the header's current height like scrollToUnit) rather than centred behind it. Cards
- // has no pinned header, so the actionable row is centred as it was.
+ // In the list the header is pinned over the page: land the block below it (block:'start',
+ // fed the header's current height like scrollToUnit) rather than behind it. Cards has no
+ // pinned header, so the actionable row is centred as it was.
if (listMode) {
const hdrH = hdrRef.current?.offsetHeight
if (hdrH) listRef.current?.style.setProperty('--whdr-h', hdrH + 'px')
diff --git a/frontend/src/views/Workout.superset-list-scroll.test.jsx b/frontend/src/views/Workout.superset-list-scroll.test.jsx
index c12c7c42b..c16e1f44f 100644
--- a/frontend/src/views/Workout.superset-list-scroll.test.jsx
+++ b/frontend/src/views/Workout.superset-list-scroll.test.jsx
@@ -125,11 +125,13 @@ for (const view of ['list', 'compact']) {
await press(container.querySelector('[role="checkbox"]'))
await rerender()
expect(mocks.S.active.cur).toBe(1)
- // The partner B's first row is the 3rd .setrow (A has 2, then B's first).
- const partnerRow = container.querySelectorAll('.setrow')[2]
- expect(seen).toContain(partnerRow)
- // The row is scrolled to the top under the pinned header, with the header's height fed to
- // --whdr-h so the row's scroll-margin (index.css) clears it rather than hiding behind it.
+ // The list brings the partner's exercise BLOCK (its name first) up under the header, not
+ // its set field: you want to see which exercise you are on, then the row.
+ const partnerBlock = container.querySelector('.ss-ex[data-exidx="1"]')
+ expect(partnerBlock).toBeTruthy()
+ expect(seen).toContain(partnerBlock)
+ // Landed under the pinned header, with the header's height fed to --whdr-h so the block's
+ // scroll-margin (index.css) clears it rather than hiding behind it.
expect(container.querySelector('.workout-list').style.getPropertyValue('--whdr-h')).toBe('120px')
})
@@ -140,14 +142,34 @@ for (const view of ['list', 'compact']) {
await press(box(l => /Left/.test(l) && /Set 1/.test(l))); await rerender()
expect(mocks.S.active.cur).toBe(0)
expect(seen).toHaveLength(0)
- // A set 0 Right — set done, advance to partner B, scroll to B's row
+ // A set 0 Right — set done, advance to partner B, scroll to B's exercise block (its title)
await press(box(l => /Right/.test(l) && /Set 1/.test(l))); await rerender()
expect(mocks.S.active.cur).toBe(1)
- // A (one-sided) rows carry both `setrow` and `side`; B (normal) rows are a plain `.setrow`.
- // The partner is B's first unticked plain row.
- const partnerRow = [...container.querySelectorAll('.setrow:not(.side)')].find(el => !el.className.includes('done'))
- expect(partnerRow).toBeTruthy()
- expect(seen).toContain(partnerRow)
+ const partnerBlock = container.querySelector('.ss-ex[data-exidx="1"]')
+ expect(partnerBlock).toBeTruthy()
+ expect(seen).toContain(partnerBlock)
+ })
+
+ // The real-session order: rate each side (effort on), so each side tick closes the effort
+ // picker, which arms the scroll-restore window. The partner's scroll must survive the wait.
+ it('a one-sided member with effort rating still scrolls to the partner', async () => {
+ await mount([oneSided('0025', 'g'), normal('0043', 'g'), normal('0001')], 0, view)
+ mocks.S = { ...mocks.S, effort: 'rir' }; await rerender()
+ const seen = watchScrolls()
+ // Both sides ticked via their checkboxes (ticking is what advances, regardless of effort).
+ await press(box(l => /Left/.test(l) && /Set 1/.test(l))); await rerender()
+ // The restore window is open when the set completes (a sheet closed in the same tap).
+ mocks.scrollRestorePending.mockImplementation(() => true)
+ const queued = []
+ mocks.afterScrollRestore.mockImplementation(fn => { queued.push(fn); return () => {} })
+ await press(box(l => /Right/.test(l) && /Set 1/.test(l))); await rerender()
+ expect(mocks.S.active.cur).toBe(1)
+ expect(queued).toHaveLength(1)
+ // Another write lands before the wait is over (the store clones state, re-keying refs).
+ mocks.storeSnapshot().update(s => { s.active.entries[1].sets[0].w = 62.5 }); await rerender()
+ await act(async () => { queued[0]() })
+ const partnerBlock = container.querySelector('.ss-ex[data-exidx="1"]')
+ expect(seen).toContain(partnerBlock)
})
})
}