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.

fix(routines): preserve drop click suppression

Space_Hermesda161613cf4a
diff --git a/frontend/src/views/RoutineEdit.drag.test.jsx b/frontend/src/views/RoutineEdit.drag.test.jsx
index 63749ccd1..5ced70b62 100644
--- a/frontend/src/views/RoutineEdit.drag.test.jsx
+++ b/frontend/src/views/RoutineEdit.drag.test.jsx
@@ -154,6 +154,18 @@ describe('routine long-press reorder', () => {
expect(writes).toHaveBeenCalledTimes(1)
})
+ it('suppresses the compatibility click after a successful changed drop', () => {
+ const layout = mount([configured('a'), configured('b'), configured('c')])
+ const item = rows()[0].querySelector('.item')
+ lift(rows()[0], layout.centers[0])
+ pointer(item, 'pointermove', { y: layout.centers[2] + 1 })
+ pointer(item, 'pointerup', { y: layout.centers[2] + 1 })
+ expect(exercises().map(e => e.id)).toEqual(['b', 'c', 'a'])
+
+ act(() => item.click())
+ expect(sheets.exConfigSheet).not.toHaveBeenCalled()
+ })
+
it('moves a whole grouped unit, never splits another group, and preserves every occurrence payload', () => {
const pairA = configured('dup', { sg: 'pair', weight: 11, note: 'first', future: { a: 1 } })
const pairB = configured('dup', { sg: 'pair', weight: 22, note: 'second', future: { b: 2 } })
diff --git a/frontend/src/views/RoutineEdit.jsx b/frontend/src/views/RoutineEdit.jsx
index bc25c47f6..88714e1a3 100644
--- a/frontend/src/views/RoutineEdit.jsx
+++ b/frontend/src/views/RoutineEdit.jsx
@@ -93,6 +93,11 @@ function useRoutineReorder(routineIdentity, exercises, onDrop) {
onDropRef.current = onDrop
const hasRows = exercises.length > 0
+ useEffect(() => () => {
+ suppressClickRef.current = false
+ window.clearTimeout(suppressTimerRef.current)
+ }, [])
+
useEffect(() => {
const list = listRef.current
if (!list) return undefined
@@ -259,8 +264,7 @@ function useRoutineReorder(routineIdentity, exercises, onDrop) {
return () => {
const gesture = gestureRef.current
clearTimer(gesture); clearFrame(); gestureRef.current = null
- releaseCapture(gesture); suppressClickRef.current = false
- window.clearTimeout(suppressTimerRef.current)
+ releaseCapture(gesture)
document.removeEventListener('pointerdown', onPointerDown)
document.removeEventListener('pointermove', onPointerMove)
document.removeEventListener('pointerup', onPointerUp)