File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1+ import { InteractionManager } from 'react-native' ;
12import NativeHarnessUI from './NativeHarnessUI.js' ;
23import type { ElementReference } from './screen.js' ;
34
45/**
56 * Flushes pending events on the JS event loop.
67 * This ensures that any events triggered by native code (like onPress callbacks)
78 * are processed before we continue.
9+ *
10+ * Uses InteractionManager.runAfterInteractions to wait until all touch events
11+ * and animations have completed, then does additional event loop tick to
12+ * ensure React state updates are fully processed.
813 */
914const flushEvents = ( ) : Promise < void > => {
1015 return new Promise ( ( resolve ) => {
11- // setImmediate runs after I/O events but before timers
12- // This allows touch event callbacks to be processed first
13- setImmediate ( resolve ) ;
16+ // Wait for React Native to finish processing all interactions (touch events, animations)
17+ InteractionManager . runAfterInteractions ( ( ) => {
18+ // Additional event loop ticks to ensure state updates are processed
19+ setImmediate ( ( ) => {
20+ resolve ( ) ;
21+ } ) ;
22+ } ) ;
1423 } ) ;
1524} ;
1625
You can’t perform that action at this time.
0 commit comments