diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index 4ec65f9bf85ad..87fe4e8e2bf1f 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -186,7 +186,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) { if (handle._internalInstanceHandle) { nativeFabricUIManager.sendAccessibilityEvent( handle._internalInstanceHandle.stateNode.node, - eventType + eventType, ); } else { legacySendAccessibilityEvent(handle._nativeTag, eventType); diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index 26673e4dafc43..fdf9ebf5ac597 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -185,7 +185,7 @@ function sendAccessibilityEvent(handle: any, eventType: string) { if (handle._internalInstanceHandle) { nativeFabricUIManager.sendAccessibilityEvent( handle._internalInstanceHandle.stateNode.node, - eventType + eventType, ); } else { legacySendAccessibilityEvent(handle._nativeTag, eventType); diff --git a/packages/react-native-renderer/src/ReactNativeTypes.js b/packages/react-native-renderer/src/ReactNativeTypes.js index 4a606917d43f6..8b4ab311bff79 100644 --- a/packages/react-native-renderer/src/ReactNativeTypes.js +++ b/packages/react-native-renderer/src/ReactNativeTypes.js @@ -149,8 +149,15 @@ export type ReactNativeType = { componentOrHandle: any, ): ?ElementRef>, findNodeHandle(componentOrHandle: any): ?number, - dispatchCommand(handle: ElementRef>, command: string, args: Array): void, - sendAccessibilityEvent(handle: ElementRef>, eventType: string): void, + dispatchCommand( + handle: ElementRef>, + command: string, + args: Array, + ): void, + sendAccessibilityEvent( + handle: ElementRef>, + eventType: string, + ): void, render( element: React$Element, containerTag: any, @@ -169,8 +176,15 @@ export type ReactFabricType = { componentOrHandle: any, ): ?ElementRef>, findNodeHandle(componentOrHandle: any): ?number, - dispatchCommand(handle: ElementRef>, command: string, args: Array): void, - sendAccessibilityEvent(handle: ElementRef>, eventType: string): void, + dispatchCommand( + handle: ElementRef>, + command: string, + args: Array, + ): void, + sendAccessibilityEvent( + handle: ElementRef>, + eventType: string, + ): void, render( element: React$Element, containerTag: any, diff --git a/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js b/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js index da7912394e309..3def12a904f63 100644 --- a/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js +++ b/packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/ReactNativePrivateInterface.js @@ -40,5 +40,5 @@ module.exports = { }, get legacySendAccessibilityEvent() { return require('./legacySendAccessibilityEvent'); - } + }, }; diff --git a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js index 75e81c6f6610e..a935da5e4df63 100644 --- a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js @@ -313,10 +313,13 @@ describe('ReactFabric', () => { expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled(); ReactFabric.sendAccessibilityEvent(viewRef, 'focus'); - expect(nativeFabricUIManager.sendAccessibilityEvent).toHaveBeenCalledTimes(1); - expect( - nativeFabricUIManager.sendAccessibilityEvent, - ).toHaveBeenCalledWith(expect.any(Object), 'focus'); + expect(nativeFabricUIManager.sendAccessibilityEvent).toHaveBeenCalledTimes( + 1, + ); + expect(nativeFabricUIManager.sendAccessibilityEvent).toHaveBeenCalledWith( + expect.any(Object), + 'focus', + ); }); it('should warn and no-op if calling sendAccessibilityEvent on non native refs', () => { diff --git a/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js index 6747778f2ac5a..c266dab6020c7 100644 --- a/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js @@ -24,14 +24,16 @@ describe('created with ReactFabric called with ReactNative', () => { ReactNative = require('react-native-renderer'); jest.resetModules(); ReactNativePrivateInterface = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'); - UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface').UIManager; + UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') + .UIManager; jest.mock('shared/ReactFeatureFlags', () => require('shared/forks/ReactFeatureFlags.native-oss'), ); React = require('react'); ReactFabric = require('react-native-renderer/fabric'); - createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface').ReactNativeViewConfigRegistry.register; + createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') + .ReactNativeViewConfigRegistry.register; }); it('find Fabric instances with the RN renderer', () => { @@ -105,15 +107,17 @@ describe('created with ReactFabric called with ReactNative', () => { ReactFabric.render(, 11); expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled(); ReactNative.sendAccessibilityEvent(ref.current, 'focus'); - expect(nativeFabricUIManager.sendAccessibilityEvent).toHaveBeenCalledTimes(1); - expect( - nativeFabricUIManager.sendAccessibilityEvent, - ).toHaveBeenCalledWith(expect.any(Object), 'focus'); + expect(nativeFabricUIManager.sendAccessibilityEvent).toHaveBeenCalledTimes( + 1, + ); + expect(nativeFabricUIManager.sendAccessibilityEvent).toHaveBeenCalledWith( + expect.any(Object), + 'focus', + ); expect(UIManager.sendAccessibilityEvent).not.toBeCalled(); }); }); - describe('created with ReactNative called with ReactFabric', () => { beforeEach(() => { jest.resetModules(); @@ -202,14 +206,17 @@ describe('created with ReactNative called with ReactFabric', () => { const ref = React.createRef(); ReactNative.render(, 11); - expect(ReactNativePrivateInterface.legacySendAccessibilityEvent).not.toBeCalled(); + expect( + ReactNativePrivateInterface.legacySendAccessibilityEvent, + ).not.toBeCalled(); ReactFabric.sendAccessibilityEvent(ref.current, 'focus'); - expect(ReactNativePrivateInterface.legacySendAccessibilityEvent).toHaveBeenCalledTimes(1); + expect( + ReactNativePrivateInterface.legacySendAccessibilityEvent, + ).toHaveBeenCalledTimes(1); expect( ReactNativePrivateInterface.legacySendAccessibilityEvent, ).toHaveBeenCalledWith(expect.any(Number), 'focus'); expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled(); }); - }); diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js index 1a4719a1f7631..9026bef793767 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js @@ -34,7 +34,8 @@ describe('ReactNative', () => { StrictMode = React.StrictMode; ReactNative = require('react-native-renderer'); ReactNativePrivateInterface = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface'); - UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface').UIManager; + UIManager = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') + .UIManager; createReactNativeComponentClass = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') .ReactNativeViewConfigRegistry.register; TextInputState = require('react-native/Libraries/ReactPrivate/ReactNativePrivateInterface') @@ -174,9 +175,13 @@ describe('ReactNative', () => { 11, ); - expect(ReactNativePrivateInterface.legacySendAccessibilityEvent).not.toBeCalled(); + expect( + ReactNativePrivateInterface.legacySendAccessibilityEvent, + ).not.toBeCalled(); ReactNative.sendAccessibilityEvent(viewRef, 'focus'); - expect(ReactNativePrivateInterface.legacySendAccessibilityEvent).toHaveBeenCalledTimes(1); + expect( + ReactNativePrivateInterface.legacySendAccessibilityEvent, + ).toHaveBeenCalledTimes(1); expect( ReactNativePrivateInterface.legacySendAccessibilityEvent, ).toHaveBeenCalledWith(expect.any(Number), 'focus'); diff --git a/scripts/flow/react-native-host-hooks.js b/scripts/flow/react-native-host-hooks.js index c42159e0fc22e..9f5c13a9f33c7 100644 --- a/scripts/flow/react-native-host-hooks.js +++ b/scripts/flow/react-native-host-hooks.js @@ -110,6 +110,7 @@ declare module 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface' ) => void, ... }; + declare export var legacySendAccessibilityEvent: (reactTag: number, eventTypeName: string) => void; declare export var BatchedBridge: { registerCallableModule: (name: string, module: Object) => void, ... @@ -156,6 +157,7 @@ declare var nativeFabricUIManager: { ) => void, dispatchCommand: (node: Object, command: string, args: Array) => void, + sendAccessibilityEvent: (node: Object, eventTypeName: string) => void, measure: (node: Node, callback: MeasureOnSuccessCallback) => void, measureInWindow: (