react-native: accessibilityLabel does not work for Text component on iOS

Description

Continuing the discussion from https://github.com/facebook/react-native/issues/13648#issuecomment-303046218, for <Text> component on iOS, the actual label of the text always overrides the testID and accessibilityLabel

Reproduction Steps and Sample Code

  1. Create a new RN app using react-native init
  2. Edit index.ios.js
  3. Find the “Welcome to React Native” text and change it to
<Text testID={'welcome'} accessibilityLabel={'welcome'}>Welcome to React Native!</Text>
  1. Run this app on an iOS simulator and inspect it with Accessibility Inspector

Expected: The Accessibility Inspector should say the Label is welcome. Actual: The Accessibility Inspector says the Label is Welcome to React Native!.

Note: - with the same set of properties on Android the contentDescription is welcome which is what I expect.

Additional Information

  • React Native version: 0.44.0
  • Platform: iOS 10.1 Simulator
  • Development Operating System: Mac OSX 10.11.6
  • Dev tools: XCode 8.1, Accessibility Inspector 5.0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 11
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@curioustechizen @vasyares The fix has been made and is in a PR. Setting the accessibilityLabel of a <Text> component will now return the correct value as expected.