Repository navigation
fix(View): do not flatten a view that is a live region - #59335
faciledictu wants to merge 1 commit into
Conversation
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D126905304. |
|
This pull request was successfully merged by @faciledictu in 5e13324 When will my fix make it into a release? | How to file a pick request? |
|
A correction to the summary above. I wrote that a live region needs a view of its own "unlike a hint or a label", because those are only announced on an On the same Samsung SM-A276B (Android 16, TalkBack 16.2) and React Native 0.88.0, a <View accessibilityLabel="Cart L1">
<Text>3 items L1</Text>
</View>
<View accessibilityLabel="Cart L2" collapsable={false}>
<Text>3 items L2 (control)</Text>
</View>TalkBack reads L2 as "Cart L2"; L1 is flattened and only "3 items L1" is read. So the |
Summary: Fixes react#59329. Related: react#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: react#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 react#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: 33cf5f191b20ce9253e669c95b8d95970a86517b
Summary:
Fixes #59329. Related: #59330 (
aria-liveonText).A
Viewwitharia-liveoraccessibilityLiveRegionand no style isflattened by Fabric:
ViewShadowNode::initializekeeps a host view foraccessibilityViewIsModal,accessibilityElementsHiddenandimportantForAccessibility, but not foraccessibilityLiveRegion. The liveregion never reaches the native tree, so TalkBack never announces changes to
its children. The only workaround is
collapsable={false}, which is notdocumented for live regions.
This adds
accessibilityLiveRegion != Noneto the conditions that form astacking context, next to
accessibilityViewIsModal. The prop only has aneffect 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
HostPlatformViewTraitsInitializerinstead if you prefer.This inverts the existing
does not unflatten viewtest foraccessibilityLiveRegion: unlike a hint or a label, a live region is announcedwithout the view being
accessible, so it needs a view of its own.Changelog:
[ANDROID] [FIXED] - A
Viewwitharia-liveoraccessibilityLiveRegionis no longer flattened, so the live region is announcedTest Plan:
Added a Fantom test:
<View aria-live="polite" />withoutcollapsableoraccessibleis rendered as a host view withaccessibilityLiveRegion="polite"(before the change it was flattened and the output was
null). The existingaccessibilityLiveRegiontestdoes not unflatten viewasserted the oldbehavior, so it is now
unflattens viewand 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.