-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Fabric] Implement nativeID #14659
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
base: main
Are you sure you want to change the base?
[Fabric] Implement nativeID #14659
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements nativeID support for Fabric by mapping the nativeID property as a fallback to the UI Automation AutomationId property when testID is absent.
- C++ changes update the automation provider to use nativeID as a fallback.
- The TSX sample is updated to demonstrate usage of the new nativeID prop.
- A JSON changelog entry has been added to document the change.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp | Updates the UI Automation property retrieval to use nativeID as fallback when testID is empty. |
packages/playground/Samples/text.tsx | Adds nativeID prop to the Text component in the playground sample. |
change/react-native-windows-c1f73033-6623-45cb-a6ee-f64376e9e1e4.json | Adds a changelog entry marking the PR as a prerelease patch change. |
Comments suppressed due to low confidence (2)
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp:489
- Ensure that fallback to props->nativeId is intentional; if both testId and nativeId might be empty, consider adding explicit handling of such cases.
auto wideId = !props->testId.empty() ? (::Microsoft::Common::Unicode::Utf8ToUtf16(props->testId)) : (::Microsoft::Common::Unicode::Utf8ToUtf16(props->nativeId));
packages/playground/Samples/text.tsx:15
- [nitpick] The nativeID prop value 'nativeId_Test' uses mixed casing; consider standardizing the casing for nativeID values to improve consistency and readability.
<Text nativeID="nativeId_Test" style={styles.welcome}>
I don't think I agree with nativeId being the same as testId. testId gets mapped to accessibility properties for usage in automation. nativeId is supposed to allow native code to reference the component. For that we'd need a native method to access the nativeId of a component - so a new public property on MS.RN.ComponentView. And a way to look up a ComponentView from a nativeId -- Something like MS.RN.Compositon.CompositionUIService.ComponentFromReactTag, but that looks up the component based on nativeId instead of react tag. Although putting it on CompositionUIService might not make sense either. Or it may require a view to search from. Looking at the android impl, in ReactFindViewUtil, I think there is a need to be able to search for a nativeId on a specific UI tree. |
Description
Type of Change
Why
[Fabric] Implement nativeID
Resolves #13830 #13728 #12514
What
[Fabric] Implemented nativeID
Mapped native Id to UIA_AutomationIdPropertyId
Screenshots
Testing
Playground composition tested
Changelog
Should this change be included in the release notes: Yes
Add a brief summary of the change to use in the release notes for the next release. [Fabric] Implement nativeID
Microsoft Reviewers: Open in CodeFlow