Commit 816dd4e
authored
Complete
## 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](https://reactnative.dev/docs/pressable#how-it-works).
### Completion checklist
- `onPress*`
- [x] callbacks
- [x] support `hitSlop` (does not work on `MacOS`)
- [x] support `pressRetentionOffset`
- [x] support `unstable_pressDelay`
- `onHover*`
- [x] callback
- [x] support `delayHoverIn`, `delayHoverOut`
- `onLongPress`
- [x] callback
- [x] support `delayLongPress`
- [x] ref passthrough support
- `Android`
- [x] works on `fabric`
- [x] works on `paper`
- `iOS`
- 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] works on `fabric`
- [x] works on `paper`
- [x] `Web` support
- `MacOS`
- [ ] works on `fabric` (could not test on my setup)
- [x] works 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.Pressable refactor. (#3571)1 parent 6e31b0b commit 816dd4e
7 files changed
Lines changed: 591 additions & 467 deletions
File tree
- apps/common-app/src
- new_api/pressable
- release_tests/nestedPressables
- packages/react-native-gesture-handler/src/components/Pressable
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | | - | |
44 | | - | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
59 | 62 | | |
60 | 63 | | |
61 | 64 | | |
62 | | - | |
63 | | - | |
64 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
72 | 75 | | |
73 | 76 | | |
74 | 77 | | |
| |||
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
82 | | - | |
83 | | - | |
| 85 | + | |
| 86 | + | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | | - | |
88 | | - | |
| 90 | + | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| |||
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
85 | 101 | | |
86 | 102 | | |
87 | 103 | | |
| |||
0 commit comments