Skip to content

Commit 55b5269

Browse files
authored
fix: Active item getting stuck on iOS 26 (#494)
## Description For some reason the `onFinalize` method is no longer called on the gesture detector when the manual gesture manager's `end` method is called. I moved the `handleDragEnd` call to the `onTouchesUp` and `onTouchesCancelled` methods to call it directly without relying on the `onFinalize` callback.
1 parent 479480a commit 55b5269

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/react-native-sortables/src/providers/shared/DragProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,6 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
508508
const ctx = context.value;
509509
clearAnimatedTimeout(ctx.activationTimeoutId);
510510

511-
const fromIndex = ctx.dragStartIndex;
512-
const toIndex = keyToIndex.value[key]!;
513-
514511
ctx.touchStartTouch = null;
515512
currentTouch.value = null;
516513
activationState.value = DragActivationState.INACTIVE;
@@ -528,6 +525,9 @@ const { DragProvider, useDragContext } = createProvider('Drag')<
528525
multiZoneActiveItemDimensions.value = null;
529526
}
530527

528+
const fromIndex = ctx.dragStartIndex;
529+
const toIndex = keyToIndex.value[key]!;
530+
531531
prevActiveItemKey.value = activeItemKey.value;
532532
ctx.dragStartItemTouchOffset = null;
533533
ctx.dragStartTouchPosition = null;

packages/react-native-sortables/src/providers/shared/hooks/useItemPanGesture.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ export default function useItemPanGesture(
2727
handleTouchesMove(e, manager.fail);
2828
})
2929
.onTouchesCancelled((_, manager) => {
30+
handleDragEnd(key, activationAnimationProgress);
3031
manager.fail();
3132
})
3233
.onTouchesUp((_, manager) => {
33-
manager.end();
34-
})
35-
.onFinalize(() => {
3634
handleDragEnd(key, activationAnimationProgress);
35+
manager.end();
3736
}),
3837
[
3938
handleDragEnd,

0 commit comments

Comments
 (0)