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
This commit is contained in:
Rubén Norte authored and GitHub committed 2026-10-27 18:54:43 +00:00
1 parent eb90a8d251
commit eaf4c26110
1 file changed
+45 -53
@@ -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<React.ElementRef<typeof View>>();
const secondRef = React.createRef<React.ElementRef<typeof View>>();
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<React.ElementRef<typeof View>>();
const secondRef = React.createRef<React.ElementRef<typeof View>>();
const onFirstResponderGrant = jest.fn();
const onSecondResponderGrant = jest.fn();
Fantom.runTask(() => {
root.render(
<View
key="first"
ref={firstRef}
onStartShouldSetResponder={() => true}
onResponderGrant={onFirstResponderGrant}
/>,
);
});
Fantom.runTask(() => {
root.render(
<View
key="first"
ref={firstRef}
onStartShouldSetResponder={() => 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(
<View
key="second"
ref={secondRef}
onStartShouldSetResponder={() => true}
onResponderGrant={onSecondResponderGrant}
/>,
);
});
Fantom.runTask(() => {
root.render(
<View
key="second"
ref={secondRef}
onStartShouldSetResponder={() => 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();