Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong translation from react-native's accessibilityLabel to iOS name/label #21830

Closed
melchior-by opened this issue Oct 17, 2018 · 5 comments
Closed
Labels
Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@melchior-by
Copy link

melchior-by commented Oct 17, 2018

Environment

OS: macOS High Sierra 10.13.6
Node: 10.8.0
Yarn: Not Found
npm: 6.4.1
Watchman: Not Found
Xcode: Xcode 10.0 Build version 10A255
Android Studio: 3.1 AI-173.4907809

Packages: (wanted => installed)
react: ^16.4.1 => 16.4.1
react-native: ^0.55.4 => 0.55.4

Description

When accessibilityLabel set to the element in react-native code it translates to the iOS name/label, but all parent element's name/label accumulate accessibilityLabel value of a child element.

In Appium inspector it's looks like:

<e1 name ='label 2 label 1'>
  <e2 name ='label 2'>
    <e3 name ='label 1'>
      <e4 name ='label 1'>

But in native code:

<e1>
  <e2 accessibilityLabel ='label 2'>
    <e3>
      <e4 accessibilityLabel ='label 1'>

It completely ruins all efforts to automate testing of iOS app built from react-native code.
I investigated this issue and found it appears from work of RCTRecursiveAccessibilityLabel() function, which called in RCTView.m file in this code:

- (NSString *)accessibilityLabel
{
  NSString *label = super.accessibilityLabel;
  if (label) {
    return label;
  }
  return RCTRecursiveAccessibilityLabel(self);
}

Change return RCTRecursiveAccessibilityLabel(self); to return nil; - fix this issue, so I suggest this code changes to be implemented.

@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the issue still exists.

The ":rewind:Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Nov 1, 2018
@LorandP
Copy link

LorandP commented Mar 21, 2019

This problem is still persisting on 0.57.7 as well so this should be reopened

@lucaGazzola
Copy link

Is there a plan of fixing this behaviour in upcoming releases? Testing iOS applications using appium is hell atm

@ZacMilano
Copy link

This issue persists for me on 58.6

@facebook facebook locked as resolved and limited conversation to collaborators Nov 1, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Nov 1, 2019
nfriedly added a commit to nfriedly/react-native that referenced this issue Aug 25, 2020
I came across this because one of my customer's apps was freezing the UI and crashing after spending ~10 seconds when trying to read the accessibilityLabel of a view with a "particularly complex and dynamic view hierarchy". I'm still not entirely sure what the app was doing, but I believe this will sidestep the issue entirely.

I believe this change will also improve both the accessibility and the testability of RN apps, in addition to fixing that crash.

This PR supersedes or fixes facebook#21830, facebook#25963, facebook#24113, facebook#24118, appium/appium#10654, possibly facebook#25220, and probably a few other tickets I haven't identified.

Also worth mentioning that there is very similar code in https://github.com/facebook/react-native/blob/master/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm#L489-L515 - I haven't dug into that as much, but I suspect it should probably get the same treatment. If anyone wants, I can include it in this PR.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
5 participants