Skip to content

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

Merged
merged 7 commits into from
May 24, 2025

Conversation

MatiPl01
Copy link
Owner

@MatiPl01 MatiPl01 commented May 23, 2025

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

Before After
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

@MatiPl01 MatiPl01 self-assigned this May 23, 2025
@MatiPl01 MatiPl01 added enhancement New feature or request fix labels May 23, 2025
Copy link

vercel bot commented May 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
react-native-sortables-docs ⬜️ Ignored (Inspect) Visit Preview May 24, 2025 6:02pm

@MatiPl01 MatiPl01 requested a review from Copilot May 24, 2025 18:09
Copy link
Contributor

@Copilot Copilot AI left a 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),

@MatiPl01 MatiPl01 marked this pull request as ready for review May 24, 2025 18:17
@MatiPl01 MatiPl01 merged commit 07065b5 into main May 24, 2025
6 checks passed
@MatiPl01 MatiPl01 deleted the fix/press-not-working-with-small-activation-delay branch May 24, 2025 18:18
MatiPl01 added a commit that referenced this pull request May 26, 2025
## 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.
MatiPl01 pushed a commit that referenced this pull request May 26, 2025
# [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))
@MatiPl01
Copy link
Owner Author

🎉 This issue has been resolved in version 1.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant