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.

Routine editor: the exercise name is the row's button, not the whole row, so the superset link and Move buttons stay reachable for VoiceOver and TalkBack; the long press still lifts from the name

Duarte Santosd1ec7f89ed97
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 98c36e0bc..d6e4904cc 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -523,6 +523,10 @@ h4.sec{
.item .tt{font-size:16px;font-weight:400;line-height:1.25;letter-spacing:-.009em}
.item .ss{color:var(--label-2);font-size:13px;margin-top:2px}
.item .grow{flex:1;min-width:0}
+/* A row's opener as a real button (the routine editor's exercise name), so a row holding other
+ buttons is no button itself. Reads as the plain text it replaced. */
+.item .item-open{display:flex;flex-direction:column;justify-content:center;align-self:stretch;text-align:start}
+.item .item-open>span{display:block}
.chev{color:var(--label);flex:none;font-size:15px;--icon-stroke:2.4}
.tag{
display:inline-flex;align-items:center;gap:3px;background:var(--surface-2);
diff --git a/frontend/src/views/RoutineEdit.jsx b/frontend/src/views/RoutineEdit.jsx
index a0933dd3c..86b03f8c5 100644
--- a/frontend/src/views/RoutineEdit.jsx
+++ b/frontend/src/views/RoutineEdit.jsx
@@ -14,7 +14,6 @@ import { glyphOf } from '../lib/glyphs.js'
import { Button, Row, SelectRow, Switch } from '../components/ui.jsx'
import SwipeRow from '../components/SwipeRow.jsx'
import { workoutControls } from '../lib/workout-controls.js'
-import { tappable } from '../lib/use-sheet-keyboard.js'
import { copyRoutine, deleteRoutine, replaceSlotExercise } from '../lib/routines.js'
import { planPrintHTML, printPlan } from '../lib/plan-share.js'
import { MOBILE, printHtml } from '../lib/mobile.js'
@@ -214,7 +213,7 @@ function useRoutineReorder(routineIdentity, exercises, onDrop) {
}
if (event.isPrimary === false || (event.pointerType === 'mouse' && event.button !== 0)) return
const target = event.target
- if (!target?.closest || target.closest('button,a,input,textarea,select,[data-nodrag]')) return
+ if (!target?.closest || target.closest('button:not([data-row-open]),a,input,textarea,select,[data-nodrag]')) return
const row = target.closest('[data-routine-row]')
if (!row || !list.contains(row)) return
const sourceIndex = Number(row.dataset.exIndex)
@@ -504,17 +503,19 @@ export default function RoutineEdit() {
const leavesDown = inSS.has(i) && r.ex[i + 1]?.sg !== e.sg
const isDragging = reorder.drag && i >= reorder.drag.first && i <= reorder.drag.last
const removeHere = () => removeRoutineExercise(id, i)
- // A keyboard button too (tappable): with the swipe's delete button gone from the tab order,
- // Enter opens the exercise's sheet, and its Remove is the keyboard's way to take it out.
- const item = <div className={'item' + (inSS.has(i) ? ' in-ss' : '')} {...tappable(() => {
+ // A tap anywhere on the row opens the exercise's sheet; its Remove is the keyboard's way
+ // to take it out. The row itself is no button (it holds the link and Move buttons, which a
+ // screen reader would lose inside one): the name is, a real <button> a click bubbles up
+ // from. The long press treats it as the row (data-row-open, useRoutineReorder).
+ const item = <div className={'item' + (inSS.has(i) ? ' in-ss' : '')} onClick={() => {
exConfigSheet(ex, e, cfg => edit(x => { x[i] = { id: x[i].id, sg: x[i].sg, ...cfg } }), removeHere, r, null, () => replace(i))
- })}>
+ }}>
{/* Shown on pointer devices only (index.css .routine-grip); the Move buttons and the
long press stay the way in for a keyboard and a finger. */}
<span className="routine-grip" data-drag-handle aria-hidden="true" title={t('Reorder exercises')}><Icon name="grip" /></span>
<Thumb ex={ex} />
- <div className="grow"><div className={`tt ${exerciseNameClass(ex)}`}>{exerciseNameFor(ex)}</div><div className="ss">{exLine(e, S.unit, speedUnitOf(S))}</div>
- {e.note && <div className="small dim" style={{ marginTop: 2 }}>{e.note}</div>}</div>
+ <button type="button" className="grow item-open" data-row-open><span className={`tt ${exerciseNameClass(ex)}`}>{exerciseNameFor(ex)}</span><span className="ss">{exLine(e, S.unit, speedUnitOf(S))}</span>
+ {e.note && <span className="small dim" style={{ marginTop: 2 }}>{e.note}</span>}</button>
{noEquip && <span className="tag" style={{ color: 'var(--orange)', borderColor: 'var(--orange)' }} title={t('Needs {0}, which isn’t in your active profile', t(ex.eq))}><Icon name="warning" /></span>}
<div style={{ display: 'flex', flexDirection: 'column', gap: 2, flex: 'none', alignItems: 'center' }}>
{i > 0 && <button className={'iconbtn' + (linkedPrev ? ' on-ss' : '')} title={t('Superset with exercise above')} style={{ width: 32, height: 28, borderRadius: 8, fontSize: 15 }} onClick={ev => { ev.stopPropagation(); toggleLink(i) }}><Icon name="link" /></button>}
diff --git a/frontend/src/views/RoutineEdit.swipe.test.jsx b/frontend/src/views/RoutineEdit.swipe.test.jsx
index 7b89b44df..bce267937 100644
--- a/frontend/src/views/RoutineEdit.swipe.test.jsx
+++ b/frontend/src/views/RoutineEdit.swipe.test.jsx
@@ -102,22 +102,34 @@ describe('swiping an exercise out of a routine', () => {
expect(ex().map(e => e.id)).toEqual(['1001', '1002', '1003', '1004'])
})
- it('the row stays a keyboard button, and the sheet’s Remove has the same Undo', () => {
- mount([configured('1001'), configured('1002')])
+ it('the name is the keyboard’s button (no button inside a button), and the sheet’s Remove has the same Undo', () => {
+ mount([configured('1001', { sg: 'g1' }), configured('1002', { sg: 'g1' })])
+ // The row holds the superset link and the Move buttons, so it is no button itself: a screen
+ // reader reads a button's insides as plain text (axe nested-interactive).
+ for (const el of host.querySelectorAll('.routine-list [role="button"], .routine-list button')) {
+ expect(el.parentElement.closest('[role="button"], button')).toBeNull()
+ }
const item = swrows()[1].querySelector('.item')
- expect(item.getAttribute('role')).toBe('button')
- act(() => { item.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true })) })
+ expect(item.hasAttribute('role')).toBe(false)
+ expect(item.querySelector('button[aria-label="Move up"]')).toBeTruthy()
+ const open = item.querySelector('button.item-open')
+ expect(open.type).toBe('button')
+ click(open) // Enter or Space on a <button> is this click
expect(sheets.exConfigSheet).toHaveBeenCalledOnce()
+ click(item.querySelector('[data-thumb]')) // a tap elsewhere on the row opens it too
+ expect(sheets.exConfigSheet).toHaveBeenCalledTimes(2)
const onDelete = sheets.exConfigSheet.mock.calls[0][3]
act(() => onDelete())
expect(ex().map(e => e.id)).toEqual(['1001'])
undo()
expect(ex().map(e => e.id)).toEqual(['1001', '1002'])
+ click(swrows()[1].querySelector('button[aria-label="Move up"]')) // its own job, no sheet
+ expect(sheets.exConfigSheet).toHaveBeenCalledTimes(2)
})
- it('a row the long press has picked up does not swipe', () => {
+ it('a long press on the name picks the row up, and a row it has picked up does not swipe', () => {
mount([configured('1001'), configured('1002')])
- const item = swrows()[0].querySelector('.item')
+ const item = swrows()[0].querySelector('.item-open')
pointer(item, 'pointerdown', 200)
act(() => vi.advanceTimersByTime(ROUTINE_LONG_PRESS_MS))
expect(host.querySelector('.is-dragging')).toBeTruthy()