-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[ Fabric ] Added ariaHidden accessibility prop across all components #14836
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
Conversation
…essibility and accessibilityElementsHidden as ( android and ios )
vnext/src-win/Libraries/Components/View/ViewPropTypes.windows.js
Outdated
Show resolved
Hide resolved
@@ -333,7 +330,7 @@ const View: component( | |||
// [Windows | |||
accessible={_accessible} | |||
children={ | |||
importantForAccessibility === 'no-hide-descendants' | |||
computedImportantForAccessibility === 'no-hide-descendants' |
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.
This conditional rendering of the children using childrenWithImportantForAccessibility was a compromise to implement this property in paper since there was no good way to configure the Xaml automation peers to do what we needed. With fabric we have complete control over the automation providers we should be able to avoid using this forked code when running in fabric. I'd really like us to render children as normal when running fabric as this code has caused issues in apps.
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.
That makes sense, I actually thought of removing it but wanted to make sure this doesn't affect the current behaviour for fabric and paper . Now I have removed the conditional rendering of the children using childrenWithImportantForAccessibility for fabric and for paper It remains the same.
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.
on line 280 : children={otherProps.children} this is part of actual view which is used for fabric.
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.
Ah so to confirm this section of code on line 331 only runs on Paper apps?
…ildren : childrenWithImportantForAccessibility
Please keep the PR draft until all CI tests pass. |
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 unifies the hiding behavior for importantForAccessibility
, ariaHidden
, and accessibilityElementsHidden
across Windows views by:
- Exposing
importantForAccessibility
as a valid native prop - Computing a single
computedImportantForAccessibility
flag inView.windows.js
- Having the UI Automation provider honor hide flags on the element and its ancestors
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
vnext/src-win/Libraries/NativeComponent/BaseViewConfig.windows.js | Added importantForAccessibility to the list of forwarded view props |
vnext/src-win/Libraries/Components/View/View.windows.js | Introduced computedImportantForAccessibility , refactored prop and children logic |
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp | Added IsHiddenByParent helper and applied it in UIA property getters |
packages/e2e-test-app-fabric/test/snapshots/ViewComponentTest.test.ts.snap | Updated snapshot to reflect hidden children in ViewComponentView |
packages/@react-native-windows/tester/src/js/examples/Image/ImageExample.windows.js | Removed hard-coded importantForAccessibility from example |
change/react-native-windows-*.json | Added change entry for unified ariaHidden behavior |
Comments suppressed due to low confidence (1)
vnext/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp:542
- Ensure
strongView
is declared and refers to the currentComponentView
(or usem_view
) in this scope; otherwise, this identifier will be undefined when callingIsHiddenByParent
.
IsHiddenByParent(strongView);
? childrenWithImportantForAccessibility(otherProps.children) | ||
: otherProps.children | ||
} | ||
children={otherProps.children} |
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.
The non-Fabric branch now always passes raw children
, dropping the previous childrenWithImportantForAccessibility
wrapping. Update this to wrap based on computedImportantForAccessibility
so descendants are properly hidden.
children={otherProps.children} | |
children={ | |
computedImportantForAccessibility === 'no-hide-descendants' | |
? childrenWithImportantForAccessibility(otherProps.children) | |
: otherProps.children | |
} |
Copilot uses AI. Check for mistakes.
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.
The Changes looks good. Also we removed the conditional rendering for Fabric,that Andrew mentioned.
"_Props": {}, | ||
"__Children": [ |
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.
Which test is this connected to and why is it changing? I don't see any View tests being altered.
Also could we add some tests to this PR so we have automated validation of this behavior?
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.
Lines 596 to 600 in 02593fb
<View importantForAccessibility="no-hide-descendants"> | |
<RNTesterText> | |
This element should be hidden from accessibility. | |
</RNTesterText> | |
</View> |
Previously, we used to set accessibility to false , if importantForAccessibility="no-hide-descendants", in JS side.
But now changes , have been removed from JS. That's why it view component is displayed here.
Correct me if I am wrong @iamAbhi-916
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.
yes @vineethkuttan thats right
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.
Overall looks good. Just left a few comments. TLDR: can you add some automated tests to validate this behavior?
Description
All three properties (importantForAccessibility, ariaHidden, accessibilityElementsHidden) are properly unified to use the same underlying mechanism.
The behavior matches the expected accessibility standards where elements marked with any of these properties are hidden from assistive technologies along with their descendants ( childeren).
Type of Change
Why
What is the motivation for this change? Add a few sentences describing the context and overall goals of the pull request's commits.
(importantForAccessibility, ariaHidden, accessibilityElementsHidden) are properly unified to use the same underlying mechanism of hiding elements from assistive technologies along with their descendants ( children ).
Resolves [Add Relevant Issue Here]
#14541
What
Any of the three properties being true results in importantForAccessibility: 'no-hide-descendants'
means parent has no-hide-descendants -> IsHiddenByParent helper function correctly walks up the parent chain
Both UIA_IsContentElementPropertyId and UIA_IsControlElementPropertyId return VARIANT_FALSE when hidden
then elements are properly hidden from screen readers
Screenshots
ariahidden.mp4
Testing
tested using playground and accessibility insights
cant be tested in rntester as UIA tree for aria-hidden props would be hidden so cant compare testid
Changelog
yes
Add a brief summary of the change to use in the release notes for the next release.
Added support for (ariaHidden , importantForAccessibility, accessibilityElementsHidden) to have unified underlying behaviour acrross all components.