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 #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.