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.

Rest bar: Ready keeps every button in its slot, so a tap on +15 never lands on -15

Duarte Santos64cfcacc6db0
diff --git a/frontend/src/components/RestTimer.dock.test.jsx b/frontend/src/components/RestTimer.dock.test.jsx
index 041114e7e..8888707cd 100644
--- a/frontend/src/components/RestTimer.dock.test.jsx
+++ b/frontend/src/components/RestTimer.dock.test.jsx
@@ -50,11 +50,34 @@ describe('the docked rest bar', () => {
const bar = host.querySelector('#timer.rest')
expect(bar.querySelector('button.tclock .t').textContent).toBe('1:30')
expect(bar.querySelector('.tclock .lbl').textContent).toBe('Rest')
- expect([...bar.querySelectorAll('.acts > button')].map(b => b.getAttribute('aria-label') || b.textContent.trim()))
+ expect([...bar.querySelectorAll('.acts > button')].map(b => b.getAttribute('aria-label') || (b.querySelector('.on') || b).textContent.trim()))
.toEqual(['15s', '15s', 'Pause', 'Skip'])
expect(bar.querySelector('.tclock').getAttribute('aria-label')).toBe('1:30. Change the time left')
})
+ // QA 10-05: Ready used to drop the pause button and reflow the row, so the spot +15 had been
+ // in became −15. The slots stay put now: the pause slot is kept (inert, invisible) and Skip
+ // carries Dismiss in the same cell, so its width does not change either.
+ it('keeps every button in its slot when the rest turns Ready', () => {
+ act(() => useUI.getState().startRest(1, 0))
+ mount()
+ const slots = () => [...host.querySelectorAll('#timer .acts > button')].map(b => b.className.match(/adj|pause-slot|pause|skip/)[0])
+ expect(slots()).toEqual(['adj', 'adj', 'pause', 'skip'])
+ expect(host.querySelector('#timer .t').dataset.alt).toBe('Ready')
+ const skipCell = () => [...host.querySelectorAll('#timer .skip > span > span')].map(s => s.textContent).sort()
+ expect(skipCell()).toEqual(['Dismiss', 'Skip'])
+ act(() => vi.advanceTimersByTime(1000))
+ expect(host.querySelector('#timer .t').textContent).toBe('Ready')
+ expect(slots()).toEqual(['adj', 'adj', 'pause-slot', 'skip'])
+ expect(host.querySelector('#timer .t').dataset.alt).toBe('0:00')
+ expect(skipCell()).toEqual(['Dismiss', 'Skip'])
+ const stand = host.querySelector('#timer .pause-slot')
+ expect(stand.disabled).toBe(true)
+ expect(stand.getAttribute('aria-hidden')).toBe('true')
+ expect(stand.tabIndex).toBe(-1)
+ expect(host.querySelector('#timer .skip .off').getAttribute('aria-hidden')).toBe('true')
+ })
+
it('says Paused under the clock while the rest is held', () => {
act(() => useUI.getState().startRest(90, 0))
mount()
diff --git a/frontend/src/components/RestTimer.jsx b/frontend/src/components/RestTimer.jsx
index 546eca811..f6da3f486 100644
--- a/frontend/src/components/RestTimer.jsx
+++ b/frontend/src/components/RestTimer.jsx
@@ -75,23 +75,31 @@ export default function RestTimer() {
// −15 and +15 sit together in number-line order; Skip is pushed to the far edge, away from the
// button you tap to buy more time. Pause sits between them as an icon (#193): it holds the
// time, it neither adds nor ends it. A rest that is over has nothing left to hold, so Ready
- // offers no pause.
+ // offers no pause, but its slot stays (an invisible stand-in) and Skip is as wide as Dismiss
+ // (both labels share one cell, one of them hidden), and the clock keeps room for the other of
+ // its two faces (data-alt, a hidden line in index.css): the row never reflows when the rest
+ // turns Ready, so a thumb on +15 never lands on −15.
const label = timer.kind === 'switch' ? t('Switch sides') : timer.paused ? t('Paused') : t('Rest')
return (
<div id="timer" className={'rest' + (timer.paused ? ' paused' : '') + (timer.kind === 'switch' ? ' switch' : '') + (timer.ready ? ' ready' : '')}>
<div className="bar" aria-hidden="true"><i style={{ width: pct + '%' }} /></div>
<button type="button" className="tclock" onClick={adjustRestSheet}
aria-label={(timer.ready ? t('Ready') : clock(timer.left)) + '. ' + t('Change the time left')}>
- <span className="t" role={timer.ready ? 'status' : undefined}>{timer.ready ? t('Ready') : clock(timer.left)}</span>
+ <span className="t" role={timer.ready ? 'status' : undefined} data-alt={timer.ready ? '0:00' : t('Ready')}>{timer.ready ? t('Ready') : clock(timer.left)}</span>
<span className="lbl">{label}<Icon name="chevronDown" /></span>
</button>
<div className="acts">
<Button size="sm" className="adj" icon="minus" onClick={() => addRest(-15)}>15s</Button>
<Button size="sm" className="adj" icon="plus" disabled={!timer.ready && timer.left >= REST_MAX} onClick={() => addRest(15)}>15s</Button>
- {!timer.ready && <Button size="sm" className="pause" icon={timer.paused ? 'play' : 'pause'}
- aria-label={t(timer.paused ? 'Resume' : 'Pause')} aria-pressed={!!timer.paused}
- onClick={timer.paused ? resumeRest : pauseRest} />}
- <Button size="sm" variant="primary" className="skip" onClick={stopRest}>{t(timer.ready ? 'Dismiss' : 'Skip')}</Button>
+ {timer.ready
+ ? <Button size="sm" className="pause-slot" icon="pause" disabled tabIndex={-1} aria-hidden="true" />
+ : <Button size="sm" className="pause" icon={timer.paused ? 'play' : 'pause'}
+ aria-label={t(timer.paused ? 'Resume' : 'Pause')} aria-pressed={!!timer.paused}
+ onClick={timer.paused ? resumeRest : pauseRest} />}
+ <Button size="sm" variant="primary" className="skip" onClick={stopRest}>
+ <span className="on">{t(timer.ready ? 'Dismiss' : 'Skip')}</span>
+ <span className="off" aria-hidden="true">{t(timer.ready ? 'Skip' : 'Dismiss')}</span>
+ </Button>
</div>
</div>
)
diff --git a/frontend/src/components/RestTimer.ready.test.jsx b/frontend/src/components/RestTimer.ready.test.jsx
index c5f28cc7b..c25b5b61b 100644
--- a/frontend/src/components/RestTimer.ready.test.jsx
+++ b/frontend/src/components/RestTimer.ready.test.jsx
@@ -41,7 +41,7 @@ describe('RestTimer Ready and overtime display', () => {
expect(host.querySelector('#timer .t').textContent).toBe('Ready')
expect(host.querySelector('#timer .t').getAttribute('role')).toBe('status')
- expect(host.querySelector('#timer .skip').textContent).toBe('Dismiss')
+ expect(host.querySelector('#timer .skip .on').textContent).toBe('Dismiss')
expect(useUI.getState().timer.forIdx).toBe(4)
act(() => root.render(null))
diff --git a/frontend/src/index.css b/frontend/src/index.css
index d94fda310..ddf018ef7 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1309,6 +1309,11 @@ body.chips-dragging *{cursor:inherit}
clock fills the clock's width but does not widen it. */
#timer .tclock{flex:none;min-width:0;display:flex;flex-direction:column;align-items:flex-start;text-align:start;padding:2px 0}
#timer .t{font-size:28px;font-weight:600;line-height:1.1;letter-spacing:-.026em;font-variant-numeric:tabular-nums;white-space:nowrap}
+/* The rest clock is as wide as the wider of its two faces, the time and Ready: the face not
+ showing sits in a hidden zero-height line (data-alt), so turning Ready does not move the
+ buttons beside it. */
+#timer.rest .t{display:flex;flex-direction:column}
+#timer.rest .t::after{content:attr(data-alt);height:0;overflow:hidden;visibility:hidden}
#timer .lbl{
font-size:12px;color:var(--label-2);width:0;min-width:100%;margin-top:1px;
display:inline-flex;align-items:center;gap:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
@@ -1321,7 +1326,11 @@ body.chips-dragging *{cursor:inherit}
#timer .acts .btn.plain:active{background:var(--surface-3)}
#timer .acts .btn{flex:none}
#timer .acts .skip{min-width:min(70px,100%);flex:0 1 auto}
-#timer .acts .skip span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+#timer .acts .skip > span{display:grid;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+/* Skip and Dismiss stacked in one cell, the one not in use hidden, so the button keeps one width
+ between counting and Ready; so does the pause slot, kept invisible once the rest is over. */
+#timer .acts .skip > span > span{grid-area:1/1;min-width:0;overflow:hidden;text-overflow:ellipsis}
+#timer .acts .skip .off,#timer .acts .pause-slot{visibility:hidden}
/* A paused rest reads as held: the clock and the bar step back until it runs again. */
#timer.rest.paused .t,#timer.rest.paused .bar{opacity:.5}
/* work timer (issue #16): the same bar doing the opposite job — outlined and tinted so a
@@ -1346,7 +1355,7 @@ body.no-tabbar #timer.working{box-shadow:inset 0 var(--hair) 0 var(--acc),0 -10p
@media (max-width:399px){
#timer .acts{gap:4px}
#timer .acts .adj{padding-inline:6px;gap:1px}
- #timer .acts .pause{padding-inline:10px}
+ #timer .acts .pause,#timer .acts .pause-slot{padding-inline:10px}
#timer .acts .skip{padding-inline:10px}
}
@media (max-width:359px){