@@ -14,7 +14,6 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1414import * as Fantom from '@react-native/fantom' ;
1515import * as React from 'react' ;
1616import { View } from 'react-native' ;
17- import { ReactNativeFeatureFlags } from 'react-native/react-private-interface' ;
1817
1918// Helpers for common touch event payloads
2019function touchStart ( identifier : number = 0 ) : {
@@ -133,67 +132,60 @@ describe('Responder System', () => {
133132 expect ( onResponderRelease ) . toHaveBeenCalledTimes ( 1 ) ;
134133 } ) ;
135134
136- // TODO(react/react#38006): run this with the flag on too once the synced
137- // renderer stops dropping events whose target is null.
138- ( ReactNativeFeatureFlags . enableNativeEventTargetEventDispatching ( )
139- ? it . skip
140- : it ) (
141- 'releases the responder when the touched view unmounts before the touch ends' ,
142- ( ) => {
143- const root = Fantom . createRoot ( ) ;
144- const firstRef = React . createRef < React . ElementRef < typeof View >> ( ) ;
145- const secondRef = React . createRef < React . ElementRef < typeof View >> ( ) ;
146- const onFirstResponderGrant = jest . fn ( ) ;
147- const onSecondResponderGrant = jest . fn ( ) ;
148-
149- Fantom . runTask ( ( ) => {
150- root . render (
151- < View
152- key = "first"
153- ref = { firstRef }
154- onStartShouldSetResponder = { ( ) => true }
155- onResponderGrant = { onFirstResponderGrant }
156- /> ,
157- ) ;
158- } ) ;
135+ it ( 'releases the responder when the touched view unmounts before the touch ends' , ( ) => {
136+ const root = Fantom . createRoot ( ) ;
137+ const firstRef = React . createRef < React . ElementRef < typeof View >> ( ) ;
138+ const secondRef = React . createRef < React . ElementRef < typeof View >> ( ) ;
139+ const onFirstResponderGrant = jest . fn ( ) ;
140+ const onSecondResponderGrant = jest . fn ( ) ;
159141
160- Fantom . dispatchNativeEvent ( firstRef , 'onTouchStart' , touchStart ( ) , {
161- category : Fantom . NativeEventCategory . Discrete ,
162- } ) ;
142+ Fantom . runTask ( ( ) => {
143+ root . render (
144+ < View
145+ key = "first"
146+ ref = { firstRef }
147+ onStartShouldSetResponder = { ( ) => true }
148+ onResponderGrant = { onFirstResponderGrant }
149+ /> ,
150+ ) ;
151+ } ) ;
163152
164- expect ( onFirstResponderGrant ) . toHaveBeenCalledTimes ( 1 ) ;
153+ Fantom . dispatchNativeEvent ( firstRef , 'onTouchStart' , touchStart ( ) , {
154+ category : Fantom . NativeEventCategory . Discrete ,
155+ } ) ;
165156
166- // Queue the touch end without flushing it, then unmount the view, so the
167- // event reaches JS without a target.
168- Fantom . enqueueNativeEvent ( firstRef , 'onTouchEnd' , touchEnd ( ) , {
169- category : Fantom . NativeEventCategory . Discrete ,
170- } ) ;
157+ expect ( onFirstResponderGrant ) . toHaveBeenCalledTimes ( 1 ) ;
171158
172- Fantom . runTask ( ( ) => {
173- root . render (
174- < View
175- key = "second"
176- ref = { secondRef }
177- onStartShouldSetResponder = { ( ) => true }
178- onResponderGrant = { onSecondResponderGrant }
179- /> ,
180- ) ;
181- } ) ;
159+ // Queue the touch end without flushing it, then unmount the view, so the
160+ // event reaches JS without a target.
161+ Fantom . enqueueNativeEvent ( firstRef , 'onTouchEnd' , touchEnd ( ) , {
162+ category : Fantom . NativeEventCategory . Discrete ,
163+ } ) ;
164+
165+ Fantom . runTask ( ( ) => {
166+ root . render (
167+ < View
168+ key = "second"
169+ ref = { secondRef }
170+ onStartShouldSetResponder = { ( ) => true }
171+ onResponderGrant = { onSecondResponderGrant }
172+ /> ,
173+ ) ;
174+ } ) ;
182175
183- Fantom . flushAllNativeEvents ( ) ;
176+ Fantom . flushAllNativeEvents ( ) ;
184177
185- // The responder was released, so the next touch is granted
186- Fantom . dispatchNativeEvent ( secondRef , 'onTouchStart' , touchStart ( ) , {
187- category : Fantom . NativeEventCategory . Discrete ,
188- } ) ;
178+ // The responder was released, so the next touch is granted
179+ Fantom . dispatchNativeEvent ( secondRef , 'onTouchStart' , touchStart ( ) , {
180+ category : Fantom . NativeEventCategory . Discrete ,
181+ } ) ;
189182
190- expect ( onSecondResponderGrant ) . toHaveBeenCalledTimes ( 1 ) ;
183+ expect ( onSecondResponderGrant ) . toHaveBeenCalledTimes ( 1 ) ;
191184
192- Fantom . dispatchNativeEvent ( secondRef , 'onTouchEnd' , touchEnd ( ) , {
193- category : Fantom . NativeEventCategory . Discrete ,
194- } ) ;
195- } ,
196- ) ;
185+ Fantom . dispatchNativeEvent ( secondRef , 'onTouchEnd' , touchEnd ( ) , {
186+ category : Fantom . NativeEventCategory . Discrete ,
187+ } ) ;
188+ } ) ;
197189
198190 it ( 'dispatches responderTerminate on touch cancel' , ( ) => {
199191 const root = Fantom . createRoot ( ) ;
0 commit comments