react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Add support for `accessibilityLiveRegion` / `aria-live`

Open YajurG opened this issue 2 years ago • 0 comments

Add support for accessibilityLiveRegion / aria-live prop.

Documentation

accessibilityLiveRegion Documentation

Behavior

When components dynamically change, we want TalkBack to alert the end user. This is made possible by the accessibilityLiveRegion property. It can be set to none, polite, and assertive:

Value Description
none Accessibility services should not announce changes to this view.
polite Accessibility services should announce changes to this view.
assertive Accessibility services should interrupt ongoing speech to immediately announce changes to this view.
<TouchableWithoutFeedback onPress={addOne}>
  <View style={styles.embedded}>
    <Text>Click me</Text>
  </View>
</TouchableWithoutFeedback>
<Text accessibilityLiveRegion="polite">
  Clicked {count} times
</Text>

In the above example method addOne changes the state variable count. When the TouchableWithoutFeedback is triggered, TalkBack reads the text in the Text view because of its accessibilityLiveRegion="polite" property.

The accessibilityLiveRegion prop should set the value of LiveSetting attached property. See here. The value of the LiveSetting will be a value in the AutomationLiveSetting enum (See here for documentation)

Implementation on Paper

https://github.com/microsoft/react-native-windows/blob/78f9316b769b17a0d3bbede46a58ce845619fafc/vnext/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp#L301-L317 https://github.com/microsoft/react-native-windows/blob/78f9316b769b17a0d3bbede46a58ce845619fafc/vnext/Microsoft.ReactNative/Utils/AccessibilityUtils.cpp#L15-L24

Implementation Plan

We should:

  1. Take the value of the accessibilityLiveRegion prop and set the value of the LiveSetting property to match the prop value.

To Be Clarified

Unclear if an additional call is needed to UIA to indicate to the screen reader that the LiveSetting has changed and content may need to be reannounced or if UIA will handle this automatically.

YajurG avatar Dec 08 '23 01:12 YajurG