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.

Workout: the card a swipe slides in shows its progression line, so it no longer grows by that line when it lands

Duarte Santos27c632387c9a
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 967f2306c..2c05b4dbb 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -1103,7 +1103,9 @@ function ActiveWorkout() {
timerKey={timer && `${timer.endsAt}:${timer.forIdx ?? ''}`} workKey={work?.endsAt}
onNavigate={navigateUnit} renderPreview={direction => {
// The card slid in shows what the card itself will: in the editor, no hold to start
- // and no plates to load.
+ // and no plates to load; in a session, the progression line, or the card grows by it
+ // the moment it lands. It gets the card's own wiring for that — the preview is inert,
+ // so none of it can be pressed.
const adjacent = units[unitIdx + direction] || []
if (!adjacent.length) return null
return adjacent.length > 1 ? (
@@ -1111,10 +1113,10 @@ function ActiveWorkout() {
<div className="ss-hd"><Icon name="link" />{t('Superset · do these back-to-back, rest when done')}</div>
{adjacent.map((idx, k) => <div key={idx} className="ss-ex">
{k > 0 && <div className="ss-amp">+</div>}
- <ExerciseBlock entryIdx={idx} compact editing={editing} />
+ <ExerciseBlock entryIdx={idx} compact {...blockProps(idx)} />
</div>)}
</div>
- ) : <ExerciseBlock entryIdx={adjacent[0]} editing={editing} />
+ ) : <ExerciseBlock entryIdx={adjacent[0]} {...blockProps(adjacent[0])} />
}}>
{isSuperset ? (
<div className="ss-card">
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index b8cec5786..beed22454 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -1503,6 +1503,27 @@ describe('workout list view', () => {
})
})
+// The card slid in during a swipe is the card that lands (renderPreview). Rendered without the
+// progression line, it grew by that line the moment it snapped into place.
+it('shows the progression line on the card a swipe slides in, as the card itself will', async () => {
+ const planned = id => exercise(id, [false], {
+ plan: { policy: 'linear', kind: 'up', weight: 62.5, why: ['Every rep last time — {0} {1} more.', 2.5, 'kg'] },
+ })
+ await mount([planned('plain-bench'), planned('plain-row')])
+ const surface = container.querySelector('[data-testid="workout-swipe-surface"]')
+ const pointer = (type, x) => {
+ const event = new dom.Event(type, { bubbles: true })
+ Object.assign(event, { pointerId: 1, pointerType: 'touch', clientX: x, clientY: 20 })
+ return act(async () => { surface.dispatchEvent(event) })
+ }
+ await pointer('pointerdown', 250)
+ await pointer('pointermove', 150)
+ const preview = container.querySelector('.workout-swipe-preview')
+ expect(preview).toBeTruthy()
+ expect(preview.querySelector('.progline')).toBeTruthy()
+ await pointer('pointercancel', 150)
+})
+
describe('workout compact view', () => {
const units = () => [...container.querySelectorAll('.wl-unit')]
const withExtras = done => exercise('plain-bench', done, {