diff --git a/frontend/src/index.css b/frontend/src/index.css index 9fbcc37..10936fd 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 1eb5023..dee908e 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. */} -