-
Notifications
You must be signed in to change notification settings - Fork 14
fix: onPress not fired when activation delay is low #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: onPress not fired when activation delay is low #377
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #375 by fixing a bug where the onPress event isn’t fired when the activation delay is low. The changes involve refactoring gesture handling and custom handle implementations, renaming and removing legacy components, and updating example usage accordingly.
- Updated shared types and hooks to remove deprecated parameters and introduce the new MeasuredDimensions type.
- Replaced SortableHandle and Pressable components with CustomHandle and Sortable.Touchable components.
- Updated examples and tests to reflect the new API and behavior.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
packages/react-native-sortables/src/types/providers/shared.ts | Updated type imports and removed the handleRef parameter from drag functions. |
packages/react-native-sortables/src/providers/shared/hooks/useItemPanGesture.ts | Removed handleRef dependency from gesture hook and simplified parameters. |
packages/react-native-sortables/src/providers/shared/DragProvider.ts | Refactored drag start logic to incorporate custom handle measurement and removed redundant parameters. |
packages/react-native-sortables/src/index.ts | Revised exported components, replacing SortableHandle and pressable components with CustomHandle and Sortable.Touchable. |
packages/react-native-sortables/src/components/shared/*.tsx | Removed legacy SortableHandle and createSortableTouchable while adding new implementations for CustomHandle and SortableTouchable. |
Example files | Updated example components to use the new onTap prop and new component names. |
Comments suppressed due to low confidence (2)
packages/react-native-sortables/src/providers/shared/DragProvider.ts:469
- Ensure that resetting activeHandleMeasurements to null here correctly aligns with the lifecycle of custom handles; adding a clarifying comment here could help future maintainers understand the intent.
if (activeHandleMeasurements) { activeHandleMeasurements.value = null; }
packages/react-native-sortables/src/components/shared/SortableTouchable.tsx:26
- [nitpick] Confirm that using runOnJS(true) in the tap gesture does not adversely impact performance; consider reviewing this pattern with the latest gesture-handler guidelines to ensure optimal behavior.
.runOnJS(true),
## Description This PR fixes issues caused by recent changes introduced in the #377 PR. I modified the gesture in the custom handle component by adding the `onBegin` method to the gesture. This didn't work when the custom handle was rendered after the item (e.g. with some timeout). This PR fixes this invalid behavior and simplifies handle measurement logic a bit.
# [1.7.0](v1.6.0...v1.7.0) (2025-05-26) ### Bug Fixes * Invalid call to gesture manager when item is no longer available ([#385](#385)) ([5e5e1ca](5e5e1ca)) * Invalid custom handle measurement ([#384](#384)) ([ad03d2b](ad03d2b)), closes [#377](#377) * onPress not fired when activation delay is low ([#377](#377)) ([07065b5](07065b5)), closes [#375](#375) * Order change callback invalid keyToIndex and shadow color interpolation ([#380](#380)) ([c0b3c03](c0b3c03)) * Stop passing excessive data to the item context ([#383](#383)) ([0b466ac](0b466ac)) ### Features * Active item dropped callback, more props in drag start callback ([#381](#381)) ([ef6e6cd](ef6e6cd)) * Add keyToIndex and indexToKey to the item context ([#379](#379)) ([9166043](9166043)) * Add more params to the item drop callback ([#382](#382)) ([36fe591](36fe591)) * Add more touch events to the touchable ([#378](#378)) ([c60500f](c60500f))
🎉 This issue has been resolved in version 1.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This PR fixes the issue described in the #375 discussion.
It also removes previous implementation of pressables which didn't work well with the drag gesture handler.
Changes showcase
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-05-24.at.19.55.18.mp4
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-05-24.at.19.46.31.mp4