Repository navigation
Conversation
|
@rubennorte has imported this pull request. If you are a Meta employee, you can view this in D127796330. |
| expect(onResponderRelease).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() |
There was a problem hiding this comment.
If the behavior should be the same as before, this test should run for both versions of the feature flag and behave the same way
There was a problem hiding this comment.
I left this as is for now because the flag-on run can't pass in this PR alone. With the flag off, a touch end with a null target already goes through the legacy responder plugin and releases the responder. With the flag on, ReactFabric's dispatchEvent drops events with a null target, so they never reach dispatchNativeEvent (react/react#38006). After that guard is removed, the test can run for both flag values with the same expectations. Should I keep it here so it lands with the renderer sync, or add it in a follow-up?
There was a problem hiding this comment.
I flipped the gate in 6208d24, so the test now runs with the flag off and is skipped with the flag on. With the flag on, the synced renderer still drops touch events whose target is null before they reach dispatchNativeEvent, so that run can't pass until the renderer sync lands (react/react#38006). I left a TODO on the skip to turn it on after the sync.
| expect(onResponderGrant).toHaveBeenCalledTimes(1); | ||
|
|
||
| // The target is null when the touched view unmounted during the touch. | ||
| dispatchNativeEvent(null, 'topTouchEnd', { |
There was a problem hiding this comment.
This is an internal API and we should avoid using them in Fantom tests that should be more e2e. We should find a way to test and verify this using externally visible behaviors (e.g.: dispatching the event while unmounting the component it in the test).
There was a problem hiding this comment.
I'll remove the dispatchNativeEvent import. This case doesn't need a Fantom API change: I can queue the touch end with Fantom.enqueueNativeEvent, unmount the view, and then flush the queue. The native side then sends the event with a null target, the same as on a device. The flag-on run has the blocker from the other thread, so I'll push this test after we agree on how to handle it.
There was a problem hiding this comment.
Done in 6208d24. The test now uses only Fantom APIs. It queues the touch end, unmounts the view before the event is flushed, and then checks that a touch on a new view gets the responder.
| */ | ||
| export default function dispatchNativeEvent( | ||
| target: EventTarget, | ||
| target: EventTarget | null, |
There was a problem hiding this comment.
I'd use target: ?EventTarget in case we slip an undefined here from React instead of null.
There was a problem hiding this comment.
Changed to ?EventTarget in 6208d24, also in processResponderEvent. The existing == null check already treats undefined like null.
|
Good catch! Thanks for finding this and submitting a potential fix. Could you please address the comments so we can merge it? |
|
@rubennorte merged this pull request in f754dbd. |
|
This pull request was successfully merged by @lazerg in f754dbd When will my fix make it into a release? | How to file a pick request? |
## Summary With `enableNativeEventTargetEventDispatching` on, the Fabric renderer skipped `dispatchNativeEvent` when the touched view had already unmounted, so the touch end never reached the JS responder and the next tap got lost. This passes the null target through instead, so React Native can still release the responder. It needs react/react-native#59522 to land first, since `dispatchNativeEvent` there throws on a null target today. Fixes #38006 ## How did you test this change? Added a test in `ReactFabric-test.internal.js` that unmounts a view, dispatches a touch end to its old instance handle, and expects `dispatchNativeEvent` to get a null target. It fails on main and passes with this change. Also ran `yarn test packages/react-native-renderer` (default, `--prod`, www-modern), `yarn flow fabric`, `yarn linc` and `yarn prettier-check`.
## Summary With `enableNativeEventTargetEventDispatching` on, the Fabric renderer skipped `dispatchNativeEvent` when the touched view had already unmounted, so the touch end never reached the JS responder and the next tap got lost. This passes the null target through instead, so React Native can still release the responder. It needs react/react-native#59522 to land first, since `dispatchNativeEvent` there throws on a null target today. Fixes #38006 ## How did you test this change? Added a test in `ReactFabric-test.internal.js` that unmounts a view, dispatches a touch end to its old instance handle, and expects `dispatchNativeEvent` to get a null target. It fails on main and passes with this change. Also ran `yarn test packages/react-native-renderer` (default, `--prod`, www-modern), `yarn flow fabric`, `yarn linc` and `yarn prettier-check`. DiffTrain build for [dc9aed3](dc9aed3)
) 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 react#59519 ## Changelog: [GENERAL] [FIXED] - Fix the responder not being released when a touch ends after its view unmounted Pull Request resolved: react#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: 3c3547998b3b079a540e8cdf8e904ee95a855515
* Move CI and the project to Node 22 (#100) Pin Node 22 in .nvmrc and point every workflow's setup-node at it (CI was still on Node 20), so a local shell, CI and the agent workflows read one version. Declare engines.node as ^22.13.0 || ^24.0.0: Expo SDK 58 needs 22.13 or later and does not support odd majors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Upgrade to Expo SDK 55 (React Native 0.83, React 19.2) Ran `npx expo install expo@^55.0.0 --fix`. Expo packages move to SDK-major versioning (expo-router 55, expo-notifications 55, ...). `expo install --fix` can't write to the dynamic app.config.js, so the config plugins it now wants (expo-font, expo-image, expo-secure-store) go into app.json by hand. Babel comment no longer names an SDK: babel-preset-expo adds the worklets plugin whenever react-native-worklets is installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Build the e2e simulator app for iOS 16 under Xcode 27 Xcode 27 fails to compile expo-router 55 at SDK 55's iOS 15.1 minimum: `UIAction.subtitle` resolves to an iOS 16 API in LinkPreviewNativeActionView. Raising only the pods isn't enough, since the app target then can't import iOS 16 modules, so the e2e script raises the app target, Podfile platform and every pod target to 16.0. Only the local simulator build changes; EAS builds with Xcode 26 and keeps 15.1. SDK 56 raises Expo's minimum to 16.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Upgrade to Expo SDK 56 (React Native 0.85, React 19.2.3) Ran `npx expo install expo@^56.0.0 --fix`, re-pinned expo to ~56.0.24. Reanimated 4.3, Worklets 0.8, TypeScript 6.0. `expo install --fix` can't write to the dynamic app.config.js, so the config plugin it now wants (expo-status-bar) goes into app.json by hand. jest-expo 56 takes the React Native Jest preset as a peer dependency, now in its own package: add @react-native/jest-preset matching RN 0.85. Ran `npx expo-codemod sdk-56-expo-router-react-navigation-replace` over app/ and src/: nothing to change, we import nothing from @react-navigation. Not shippable on its own: SDK 56 has a Hermes v1 memory regression with Reanimated/Worklets that SDK 57 fixes (expo-doctor flags it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep the floating tab bar's blur filling the pill on React Native 0.85 RN 0.85 drops StyleSheet.absoluteFillObject. Spreading it gave only `overflow: 'hidden'`, so the blur and veil behind the tab icons lost their absolute fill. The clip style moves to src/theme/layout.ts with a test and spreads StyleSheet.absoluteFill instead. Tab icons take `color: ColorValue`, the type expo-router 56 passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Upgrade to Expo SDK 57 (React Native 0.86, Reanimated 4.5, Worklets 0.10) Ran `npx expo install expo@^57.0.0 --fix`, re-pinned expo to ~57.0.34, past 57.0.9 (Hermes v1 memory regression fix, RN 0.86.2) and 57.0.17 (dev startup fix, RN 0.86.3). @react-native/jest-preset follows RN to 0.86. No new config plugins wanted. expo-doctor: 21/21. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drop the e2e script's iOS 16.0 deployment-target override SDK 56 raises Expo's iOS minimum to 16.4, which the prebuilt app target and Podfile now carry. The script's override forced 16.0, so it would now lower the target below what Expo's modules need. The Xcode 27 build of expo-router needs no workaround at 16.4: the full e2e suite passes (9/9 flows) without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Upgrade to Expo SDK 58 (React Native 0.88): prebuild adopts the UIScene life cycle SDK 58's prebuild generates a SceneDelegate and a UIApplicationSceneManifest, so dev builds linked against the iOS 27 SDK no longer crash at launch (#99). - expo 58.1.1, RN 0.88.1, React 19.3, Reanimated 4.7, Worklets 0.13, Gesture Handler 3.3, jest 30; @react-native/jest-preset pinned to RN's 0.88. - engines.node: ^24.3.0 instead of ^24.0.0, the floor Expo 58 and RN 0.88 accept. - RN 0.88 types: ColorValue now admits null and number, which Ionicons doesn't take, and ListHeaderComponent no longer takes null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Cover watchlinedev:// links through the iOS scene delegate in e2e Under the scene life cycle a running app gets links in openURLContexts and a cold start in the scene's connection options. The flow opens one screen each way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Test where a tapped push leads, once per push Pull the tap handling out of useNotificationRouting into createTapRoutes, so the tap-to-screen mapping and the cold-start dedupe have a unit test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * State the supported Node versions in the README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Name the tab icon color helper and the tab bar background style Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Say what the deep-link flow needs, like the other sign-up flows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Release the JS responder when a touched view unmounts mid-touch RN 0.88 turns on enableNativeEventTargetEventDispatching by default. The Fabric renderer then drops a touch event whose target view is gone, so it never reaches the responder system: the responder stays set and the next tap goes to it instead of the Pressable. On the recommendations screen the pull-to-refresh swipe starts on the empty state, the refetch replaces it with the new row, and the following tap on "Ajouter à ma liste" is lost. Patch react-native 0.88.1 with the upstream fix (react/react-native#59522, #59546; 0.88 backport #60467, issue #59519), applied by patch-package on install. Drop the patch once a 0.88 release ships the backport. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
) 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 react#59519 [GENERAL] [FIXED] - Fix the responder not being released when a touch ends after its view unmounted Pull Request resolved: react#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: 3c3547998b3b079a540e8cdf8e904ee95a855515 (cherry picked from commit f754dbd)
…60467) * 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 [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: 3c3547998b3b079a540e8cdf8e904ee95a855515 (cherry picked from commit f754dbd) * Sync OSS Fabric renderers for null-target native events (#59546) Summary: Regenerate the development, production, and profiling Fabric renderer bundles from React revision `dc9aed364252a34966f4f2c4a98272317fdddb60`. Native events whose view has unmounted now reach the responder system even when their event target is null. This renderer-only update retains React version `19.3.0` and leaves package metadata and dependency versions unchanged. Changelog: [General][Fixed] - Fix lost taps after a touched view unmounts when EventTarget event dispatching is enabled Reviewed By: javache Differential Revision: D127828293 Pull Request resolved: #59546 (cherry picked from commit eb90a8d) * Run the unmounted-touch responder test with both dispatch systems (#59545) Summary: Remove the flag-dependent skip from the Fantom regression test for a touched view unmounting before its touch ends. Fabric now forwards native events with a null target, so both dispatch systems must release the stale responder and grant the next touch. Keep the existing `enableNativeEventTargetEventDispatching:*` test matrix and remove the unused feature-flag import and obsolete TODO. Changelog: [Internal] ___ landed-with-radar-review Differential Revision: D127828380 Pull Request resolved: #59545 (cherry picked from commit eaf4c26) --------- Co-authored-by: lazerg <lazerg2@gmail.com>



Summary:
With
enableNativeEventTargetEventDispatchingon, a touch that ends after its view unmounted never reaches the responder, so the old responder sticks around andtrackedTouchCountstays one too high, which drops the next tap.processResponderEventalready handles a null target, butdispatchNativeEventonly accepts a non-null one and would crash indispatchTrustedEventif it got null. It now takesEventTarget | nulland returns right after the responder step when there is no target. The renderer'sdispatchEvent(ReactFabricEventEmitter.jsin 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
Test Plan:
Added a Fantom test to
ResponderEventTarget-itest.jsthat grants the responder, sendstopTouchEndwith a null target throughdispatchNativeEvent, 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: onmainit throwsTypeError: Cannot read properties of nullfromdispatchTrustedEvent, and it passes with this change.flow check, eslint and prettier are clean.