Exercise picker: the "+" adds now instead of opening the detail sheet

The "+" on a row in the exercise picker read as "add this now" but did
the same thing as tapping the row — opened the detail/config sheet —
so it added nothing until you'd scrolled past sets/reps and found the
real "Add to routine"/"Add exercise" button there.

The "+" now commits with the default config (or, mid-workout in
freestyle, the same last-session-seeded config the sheet would have
opened with) immediately, with a toast confirming what got added.
Tapping the rest of the row is unchanged — it still opens the detail
sheet, for setting sets/reps before adding.

Both call sites (routine editor, and the mid-workout "Add exercise")
get the same fix, since they share the one picker component.

No new strings — reuses 'Add "{0}"' and '"{0}" added to {1}', both
already translated in every locale.
This commit is contained in:
Horus Gonzalez committed 2026-08-30 14:31:56 -06:00
1 parent 37bbaeaee2
commit 47c1cc446f
3 files changed
+29 -6

No files matched your search

+8 -1
View File
@@ -502,7 +502,14 @@ function ExercisePicker({ onPick, close }) {
</div>}
{f.slice(0, shown).map(e => <div key={e.id} className="item" onClick={() => onPick(e)}>
<Thumb ex={e} /><div className="grow"><div className="tt capitalize">{exerciseNameFor(e)}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
{usage[e.id] && <span className="tag acc"><Icon name="starFill" /></span>}<Icon name="plus" className="chev" />
{usage[e.id] && <span className="tag acc"><Icon name="starFill" /></span>}
{/* A "+" glyph reads as "add this now" — it used to just open the same detail sheet as
tapping the row, so it added nothing until you'd scrolled past the sets/reps config
and found the real button. Now it does what it looks like: adds with the default
config right away. Tapping the row itself still opens the detail/config sheet, for
when you want to set sets/reps before adding. */}
<button className="iconbtn chev" aria-label={t('Add “{0}”', exerciseNameFor(e))} style={{ padding: 8, margin: -8 }}
onClick={ev => { ev.stopPropagation(); onPick(e, true) }}><Icon name="plus" /></button>
</div>)}
{f.length === 0 && bp === '★' && <div className="empty">{t('Nothing chosen yet — add exercises and they’ll show up here.')}</div>}
</div>
+11 -2
View File
@@ -1,11 +1,12 @@
import { useNavigate, useParams } from 'react-router-dom'
import { useEffect } from 'react'
import { useStore } from '../store/useStore.js'
import { useUI } from '../store/useUI.js'
import { exOr } from '../lib/exercises.js'
import { activeProfile, exAvailable } from '../lib/equipment.js'
import { uid } from '../lib/format.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
import { supersetUnits, cleanupSg, exLine } from '../lib/history.js'
import { supersetUnits, cleanupSg, exLine, defaultConfig } from '../lib/history.js'
import { Thumb } from '../components/Media.jsx'
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
@@ -20,6 +21,7 @@ export default function RoutineEdit() {
const { id } = useParams()
const S = useStore(s => s.S)
const update = useStore(s => s.update)
const toast = useUI(s => s.toast)
const r = S.routines.find(x => x.id === id)
useEffect(() => { if (!r) nav('/plan') }, [!!r])
// Editing here has no explicit "save" — every field change persists immediately. A single
@@ -111,7 +113,14 @@ export default function RoutineEdit() {
})()}
<div className="small dim row" style={{ margin: '10px 2px', gap: 5 }}><Icon name="link" style={{ fontSize: 13 }} />{t('Tap the link button on an exercise to superset it with the one above — you’ll do them back-to-back.')}</div>
<Button variant="primary" onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r))} icon="plus">{t('Add exercise')}</Button>
<Button variant="primary" onClick={() => exercisePicker((ex, quick) => {
if (quick) {
edit(x => x.push({ id: ex.id, ...defaultConfig(ex.id) }))
toast(t('“{0}” added to {1}', exerciseNameFor(ex), r.name))
} else {
exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r)
}
})} icon="plus">{t('Add exercise')}</Button>
<div style={{ height: 10 }} />
<Button variant="danger" onClick={() => confirmSheet({
title: t('Delete routine?'), message: t('“{0}” and its exercises will be removed.', r.name), confirmText: t('Delete'), danger: true,
+10 -3
View File
@@ -519,13 +519,13 @@ function ActiveWorkout() {
<Button trailingIcon="chevronRight" disabled={unitIdx < 0 || unitIdx >= units.length - 1} onClick={() => update(s => { s.active.cur = units[unitIdx + 1][0] })}>{t('Next')}</Button>
</div>
<div style={{ height: 10 }} />
<Button onClick={() => exercisePicker(ex => {
<Button onClick={() => exercisePicker((ex, quick) => {
const routine = S.routines.find(r => r.id === A.routineId)
const freestyle = !A.routineId
// Freestyle has no routine prescription to apply: show the last target in the config
// sheet and carry its completed rows forward. A planned session keeps its existing path.
const seed = freestyle ? freestyleConfig(S, { id: ex.id, ...defaultConfig(ex.id) }) : null
exConfigSheet(ex, null, cfg => update(s => {
const commit = cfg => update(s => {
const full = { ...cfg, id: ex.id }
const plan = freestyle ? null : nextPrescription(s, full, s.routines.find(r => r.id === s.active.routineId))
const sets = buildSets(s, full, { step: defaultIncrement(ex.id, s.unit), ...(freestyle ? { preferLast: true } : {}) })
@@ -534,7 +534,14 @@ function ActiveWorkout() {
s.active.entries.splice(insertAt, 0, { id: ex.id, target: { ...cfg }, plan, sets: applyIntensifierPlan(progressed, full) })
s.active.cur = insertAt
useUI.getState().shiftRestOwner(insertAt, 1)
}), null, routine, seed)
})
// The "+" on a picker row reads as "add this now" — routed through the same detail
// sheet before, so it added nothing until you'd scrolled past it and found the real
// button. Quick-add commits with the same default (or, freestyle, last-session) config
// the sheet would have opened with; tapping the row still opens that sheet for anyone
// who wants to set sets/reps first.
if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', exerciseNameFor(ex), routine ? routine.name : t('Freestyle'))) }
else exConfigSheet(ex, null, commit, null, routine, seed)
})} icon="plus">{t('Add exercise')}</Button>
{A.entries.length > 0 && <>
<div style={{ height: 6 }} />