fix(routines): preserve drop click suppression

This commit is contained in:
Space_Hermes committed 2026-08-27 19:33:59 +02:00
1 parent e44d9e7007
commit da161613cf
2 files changed
+18 -2

No files matched your search

@@ -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 } })
+6 -2
View File
@@ -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)