Repository navigation
Commit 5e13324
fix(View): do not flatten a view that is a live region (#59335)
Summary:
Fixes #59329. Related: #59330 (`aria-live` on `Text`).
A `View` with `aria-live` or `accessibilityLiveRegion` and no style is
flattened by Fabric: `ViewShadowNode::initialize` keeps a host view for
`accessibilityViewIsModal`, `accessibilityElementsHidden` and
`importantForAccessibility`, but not for `accessibilityLiveRegion`. The live
region never reaches the native tree, so TalkBack never announces changes to
its children. The only workaround is `collapsable={false}`, which is not
documented for live regions.
This adds `accessibilityLiveRegion != None` to the conditions that form a
stacking context, next to `accessibilityViewIsModal`. The prop only has an
effect on Android; I put it in the shared check so it is covered by Fantom and
because it is set only on views meant to be announced, but it could move to
the Android `HostPlatformViewTraitsInitializer` instead if you prefer.
This inverts the existing `does not unflatten view` test for
`accessibilityLiveRegion`: unlike a hint or a label, a live region is announced
without the view being `accessible`, so it needs a view of its own.
## Changelog:
[ANDROID] [FIXED] - A `View` with `aria-live` or `accessibilityLiveRegion` is no longer flattened, so the live region is announced
Pull Request resolved: #59335
Test Plan:
Added a Fantom test: `<View aria-live="polite" />` without `collapsable` or
`accessible` is rendered as a host view with `accessibilityLiveRegion="polite"`
(before the change it was flattened and the output was `null`). The existing
`accessibilityLiveRegion` test `does not unflatten view` asserted the old
behavior, so it is now `unflattens view` and expects the host view.
On a device (Samsung SM-A276B, Android 16, TalkBack on) with the reproducer
from #59329 and React Native 0.88.0 built from source with this change:
A, B and C are announced. Without the change, only B and C are announced.
Reviewed By: christophpurrer
Differential Revision: D126905304
Pulled By: javache
fbshipit-source-id: 33cf5f191b20ce9253e669c95b8d95970a86517b1 parent 0e041dd commit 5e13324
2 files changed
Lines changed: 17 additions & 2 deletions
File tree
- packages/react-native
- Libraries/Components/View/__tests__
- ReactCommon/react/renderer/components/view
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
604 | | - | |
| 604 | + | |
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
| 615 | + | |
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
| |||
841 | 841 | | |
842 | 842 | | |
843 | 843 | | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
844 | 858 | | |
845 | 859 | | |
846 | 860 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
0 commit comments