From eaf4c261101889c46f0efd44931e6738e7d535b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Tue, 27 Oct 2026 18:54:43 +0000 Subject: [PATCH] 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: https://github.com/react/react-native/pull/59545 --- .../__tests__/ResponderEventTarget-itest.js | 98 +++++++++---------- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js b/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js index 5016c87f635..5fe4be50658 100644 --- a/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js +++ b/packages/react-native/src/private/renderer/core/__tests__/ResponderEventTarget-itest.js @@ -14,7 +14,6 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; import * as Fantom from '@react-native/fantom'; import * as React from 'react'; import {View} from 'react-native'; -import {ReactNativeFeatureFlags} from 'react-native/react-private-interface'; // Helpers for common touch event payloads function touchStart(identifier: number = 0): { @@ -133,67 +132,60 @@ describe('Responder System', () => { expect(onResponderRelease).toHaveBeenCalledTimes(1); }); - // TODO(react/react#38006): run this with the flag on too once the synced - // renderer stops dropping events whose target is null. - (ReactNativeFeatureFlags.enableNativeEventTargetEventDispatching() - ? it.skip - : it)( - 'releases the responder when the touched view unmounts before the touch ends', - () => { - const root = Fantom.createRoot(); - const firstRef = React.createRef>(); - const secondRef = React.createRef>(); - const onFirstResponderGrant = jest.fn(); - const onSecondResponderGrant = jest.fn(); + it('releases the responder when the touched view unmounts before the touch ends', () => { + const root = Fantom.createRoot(); + const firstRef = React.createRef>(); + const secondRef = React.createRef>(); + const onFirstResponderGrant = jest.fn(); + const onSecondResponderGrant = jest.fn(); - Fantom.runTask(() => { - root.render( - true} - onResponderGrant={onFirstResponderGrant} - />, - ); - }); + Fantom.runTask(() => { + root.render( + true} + onResponderGrant={onFirstResponderGrant} + />, + ); + }); - Fantom.dispatchNativeEvent(firstRef, 'onTouchStart', touchStart(), { - category: Fantom.NativeEventCategory.Discrete, - }); + Fantom.dispatchNativeEvent(firstRef, 'onTouchStart', touchStart(), { + category: Fantom.NativeEventCategory.Discrete, + }); - expect(onFirstResponderGrant).toHaveBeenCalledTimes(1); + expect(onFirstResponderGrant).toHaveBeenCalledTimes(1); - // Queue the touch end without flushing it, then unmount the view, so the - // event reaches JS without a target. - Fantom.enqueueNativeEvent(firstRef, 'onTouchEnd', touchEnd(), { - category: Fantom.NativeEventCategory.Discrete, - }); + // Queue the touch end without flushing it, then unmount the view, so the + // event reaches JS without a target. + Fantom.enqueueNativeEvent(firstRef, 'onTouchEnd', touchEnd(), { + category: Fantom.NativeEventCategory.Discrete, + }); - Fantom.runTask(() => { - root.render( - true} - onResponderGrant={onSecondResponderGrant} - />, - ); - }); + Fantom.runTask(() => { + root.render( + true} + onResponderGrant={onSecondResponderGrant} + />, + ); + }); - Fantom.flushAllNativeEvents(); + Fantom.flushAllNativeEvents(); - // The responder was released, so the next touch is granted - Fantom.dispatchNativeEvent(secondRef, 'onTouchStart', touchStart(), { - category: Fantom.NativeEventCategory.Discrete, - }); + // The responder was released, so the next touch is granted + Fantom.dispatchNativeEvent(secondRef, 'onTouchStart', touchStart(), { + category: Fantom.NativeEventCategory.Discrete, + }); - expect(onSecondResponderGrant).toHaveBeenCalledTimes(1); + expect(onSecondResponderGrant).toHaveBeenCalledTimes(1); - Fantom.dispatchNativeEvent(secondRef, 'onTouchEnd', touchEnd(), { - category: Fantom.NativeEventCategory.Discrete, - }); - }, - ); + Fantom.dispatchNativeEvent(secondRef, 'onTouchEnd', touchEnd(), { + category: Fantom.NativeEventCategory.Discrete, + }); + }); it('dispatches responderTerminate on touch cancel', () => { const root = Fantom.createRoot();