From da161613cf4a3ebfb105e0e25f5aef678df48984 Mon Sep 17 00:00:00 2001 From: Space_Hermes Date: Thu, 27 Aug 2026 19:33:59 +0200 Subject: [PATCH] fix(routines): preserve drop click suppression --- frontend/src/views/RoutineEdit.drag.test.jsx | 12 ++++++++++++ frontend/src/views/RoutineEdit.jsx | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/RoutineEdit.drag.test.jsx b/frontend/src/views/RoutineEdit.drag.test.jsx index 63749cc..5ced70b 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 bc25c47..88714e1 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)