Repository navigation
Commit f754dbd
Process responder events for touches whose target unmounted (#59522)
Summary:
With `enableNativeEventTargetEventDispatching` on, a touch that ends after its view unmounted never reaches the responder, so the old responder sticks around and `trackedTouchCount` stays one too high, which drops the next tap. `processResponderEvent` already handles a null target, but `dispatchNativeEvent` only accepts a non-null one and would crash in `dispatchTrustedEvent` if it got null. It now takes `EventTarget | null` and returns right after the responder step when there is no target. The renderer's `dispatchEvent` (`ReactFabricEventEmitter.js` in react/react) still skips the call for a null target, so that guard has to go too before the bug is fully fixed, and this change needs to land first.
Fixes #59519
## Changelog:
[GENERAL] [FIXED] - Fix the responder not being released when a touch ends after its view unmounted
Pull Request resolved: #59522
Test Plan: Added a Fantom test to `ResponderEventTarget-itest.js` that grants the responder, sends `topTouchEnd` with a null target through `dispatchNativeEvent`, and checks that the release fires and the next touch is granted again. I couldn't build the Fantom runner locally, so I also ran the null-target case as a throwaway Jest test: on `main` it throws `TypeError: Cannot read properties of null` from `dispatchTrustedEvent`, and it passes with this change. `flow check`, eslint and prettier are clean.
Reviewed By: javache
Differential Revision: D127796330
Pulled By: rubennorte
fbshipit-source-id: 3c3547998b3b079a540e8cdf8e904ee95a8555151 parent 43a49f7 commit f754dbd
3 files changed
Lines changed: 72 additions & 3 deletions
File tree
- packages/react-native/src/private/renderer
- core/__tests__
- events
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
135 | 198 | | |
136 | 199 | | |
137 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
594 | | - | |
| 594 | + | |
595 | 595 | | |
596 | 596 | | |
597 | 597 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 | | |
52 | 58 | | |
53 | 59 | | |
| |||
0 commit comments