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 clears the sticky header at its real height — a wrapped workout name hid the current exercise's header row (QA C27)

Duarte Santosa54e4b6e8a8e
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 9fbcc375b..10936fd5f 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1165,8 +1165,10 @@ 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)}
+/* scrolled to when the list opens (#224): clear the sticky header above it. Workout.jsx
+ measures the header (--whdr-h on .workout-list, safe area included) because it grows when
+ the session name wraps; the fallback is the height of a one-line header. */
+.wl-unit{scroll-margin-top:calc(var(--whdr-h, var(--sat) + 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}
@media (max-width:400px){
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 1eb502353..dee908e53 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -590,6 +590,7 @@ function ActiveWorkout() {
// where it was before the sheet opened, in an effect cleanup that runs before this one —
// both would win over a scroll made right here. A frame asked for now runs after theirs.
const listRef = useRef(null)
+ const hdrRef = useRef(null)
useEffect(() => {
if (!listMode) return
const schedule = callback => window.requestAnimationFrame
@@ -602,6 +603,10 @@ function ActiveWorkout() {
const list = listRef.current
const el = list?.querySelector('.wl-unit.cur')
if (!el || typeof el.scrollIntoView !== 'function') return
+ // The sticky header grows when the workout name wraps; the unit's scroll margin (index.css)
+ // clears whatever height it has right now, with a one-line height as the fallback.
+ const hdrH = hdrRef.current?.offsetHeight
+ if (hdrH) list.style.setProperty('--whdr-h', hdrH + 'px')
el.scrollIntoView({ block: 'start' })
})
return () => cancel(frame)
@@ -960,7 +965,7 @@ function ActiveWorkout() {
{/* In list mode the whole session scrolls under the header, so the header (name, clock,
set counter, discard/finish, progress) stays pinned — the one thing you want in view
while you are somewhere in the middle of a long stack. Cards mode never scrolls far. */}
- <div className={'whdr' + (listMode ? ' stick' : '')}>
+ <div className={'whdr' + (listMode ? ' stick' : '')} ref={hdrRef}>
<div className="hdr">
<button className="iconbtn" aria-label={t('Discard')} onClick={() => confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); stopWork(); nav('/home') } })}><Icon name="xmark" /></button>
<div style={{ textAlign: 'center' }}><div style={{ fontWeight: 600 }}>{A.name}</div><div className="sub">{A.backfill ? fmtDate(A.d, true) : <Elapsed start={A.start} />} · {t('{0} sets', done + '/' + total)}</div></div>
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index a195acb52..d7f06abe4 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -20,6 +20,7 @@ const mocks = vi.hoisted(() => {
exConfigSheet: vi.fn(),
toast: vi.fn(),
scrollCalls: [],
+ headerHeight: 0,
swapActiveWorkoutExercise: vi.fn(),
menuSheet: vi.fn(),
effortPickerSheet: vi.fn(),
@@ -121,6 +122,10 @@ function installDom() {
dom.Element.prototype.scrollIntoView = vi.fn(function (options) {
mocks.scrollCalls.push({ node: this, options })
})
+ // linkedom has no layout; the sticky workout header reports the height a test gives it.
+ Object.defineProperty(dom.HTMLElement.prototype, 'offsetHeight', {
+ configurable: true, get() { return this.classList.contains('whdr') ? mocks.headerHeight : 0 },
+ })
globalThis.IS_REACT_ACT_ENVIRONMENT = true
container = document.getElementById('root')
root = createRoot(container)
@@ -200,6 +205,7 @@ beforeEach(() => {
mocks.timer = null
mocks.work = null
mocks.scrollCalls.length = 0
+ mocks.headerHeight = 0
})
afterEach(async () => {
@@ -1028,6 +1034,14 @@ describe('workout list view', () => {
expect(mocks.scrollCalls[0].node.classList.contains('cur')).toBe(true)
})
+ it('clears the sticky header at its measured height, not a one-line guess (QA C27)', async () => {
+ mocks.headerHeight = 143 // a routine name that wraps to three lines at 368 px
+ await mount([exercise('plain-bench', [true]), exercise('plain-row', [true]), exercise('plain-curl', [false])], 2, { workoutView: 'list' })
+ await flushFrame()
+ expect(mocks.scrollCalls.length).toBe(1)
+ expect(container.querySelector('.workout-list').style.getPropertyValue('--whdr-h')).toBe('143px')
+ })
+
it('re-anchors on the current exercise when the layout changes between list and compact (QA C1)', async () => {
await mount([exercise('plain-bench', [true]), exercise('plain-row', [true]), exercise('plain-curl', [false])], 2, { workoutView: 'list' })
await flushFrame()