Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RN: Implement sendAccessibilityEvent in RN Renderer that proxies between Fabric/non-Fabric #20554

10 changes: 10 additions & 0 deletions packages/react-native-renderer/src/ReactFabricHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ class ReactFabricHostComponent {

return;
}

sendAccessibilityEvent(eventType: string) {
if (__DEV__) {
console.warn(
'Warning: sendAccessibilityEvent is not currently supported in Fabric (coming soon)',
);
}

return;
}
}

// eslint-disable-next-line no-unused-expressions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {Instance} from './ReactNativeHostConfig';
import {
TextInputState,
UIManager,
DeprecatedAccessibilityInfo,
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import {create} from './ReactNativeAttributePayload';
Expand Down Expand Up @@ -124,6 +125,14 @@ class ReactNativeFiberHostComponent {
);
}
}

sendAccessibilityEvent(eventType: string) {
if (eventType === 'focus') {
DeprecatedAccessibilityInfo.setAccessibilityFocus(this._nativeTag);
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Fabric is not going to throw on invalid strings from JS, we probably want that behavior consistent on paper. Probably just no-op. Enforcement can come from the types

throw Error('eventType ' + eventType + ' is not currently supported.');
}
}
}

// eslint-disable-next-line no-unused-expressions
Expand Down