react-native-gesture-handler icon indicating copy to clipboard operation
react-native-gesture-handler copied to clipboard

Complete `Pressable` refactor.

Open latekvo opened this issue 5 months ago • 0 comments

Description

This PR introduces a complete Pressable refactor. New Pressable version defines sequences of events required to activate different Pressable callbacks. This approach allows for fewer edge-case controls, and features a much cleaner code base & a clear execution flow. The new implementation also makes detection and handling of new, unexpected cases much simpler.

Fixes

  • Fixes #3476
  • [iOS] Short taps were ignored when within a list
  • Ordering of onPress* was chaotic. Aligned it to the documentation.

Completion checklist

  • onPress*
    • [x] callbacks
    • [x] support hitSlop
    • [x] support unstable_pressDelay
  • onHover* callbacks
    • [x] callback
    • [x] support delayHoverIn, delayHoverOut
  • onLongPress support
    • [x] callback
    • [x] support delayLongPress
  • [x] ref passthrough support
  • Android support
    • [x] on fabric
    • [x] on paper
  • iOS support
    • Note: There's a 200ms delay before onPressIn when long-pressing in a scroll list. This is an intentional "feature" within iOS, but RN Pressable manages to avoid it.
    • [x] on fabric
    • [x] on paper
  • [x] Web support
  • MacOS support
    • [ ] on fabric
    • [x] on paper
  • [x] style & children support

Test plan

Use all the existing Pressable examples to test the behaviour of the newly added pressable.

Make sure to test on the following platforms:

  • Android fabric
  • Android paper
  • iOS fabric
  • iOS paper
  • MacOS fabric
  • MacOS paper
  • Web

Make sure to also test the following scenarios:

  • Pressable is not nested, and is not within a ScrollView
  • Pressable is nested within another Pressable, without a ScrollView
  • Pressable is nested within another Pressable, which is nested within a RNGH ScrollView
  • Pressable is nested within another Pressable, which is nested within a RN ScrollView
  • Pressable is nested within another Pressable, which is nested within a FlashList
  • Pressable with unstable_pressDelay, delayLongPress, hitSlop & pressRetentionOffset props.

latekvo avatar Jun 20 '25 18:06 latekvo