Commit b60f533
Respect accessibilityElementsHidden in recursive label aggregation (#55134)
Summary:
Pull Request resolved: #55134
When a parent View has `accessible={true}` on iOS, React Native recursively aggregates the `accessibilityLabel` values from all descendant Text components (or accessible components) to construct the parent's accessibility label for VoiceOver. However, this aggregation was **not respecting** the `accessibilityElementsHidden` prop, so any child elements with accessibility labels (even Text components marked with accessible={false}) were still being read aloud by VoiceOver.
This diff fixes the `RCTRecursiveAccessibilityLabel` function to skip subviews that have `accessibilityElementsHidden=YES`, ensuring that:
- Views marked with `accessibilityElementsHidden={true}` are properly excluded from label aggregation
- The behavior aligns with developer expectations when using this accessibility prop, since it is [described](https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios) as "similar to the Android property importantForAccessibility="no-hide-descendants".
Changelog:
[iOS][Fixed] - Ensure accessibilityElementsHidden prop is respected in recursive accessibility label aggregation
Reviewed By: joevilches
Differential Revision: D90420237
fbshipit-source-id: 5cac5290f4291b69a1a7dcad0d5cc118822d00521 parent 2a776b1 commit b60f533
2 files changed
Lines changed: 8 additions & 0 deletions
File tree
- packages/react-native/React
- Fabric/Mounting/ComponentViews/View
- Views
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1360 | 1360 | | |
1361 | 1361 | | |
1362 | 1362 | | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
1363 | 1367 | | |
1364 | 1368 | | |
1365 | 1369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| |||
0 commit comments