Description
Description
When adding an accessibilityLabel to a view, on iOS that accessibility label is not reaching the function that is handling the label.
We have discovered this issue while importing a .ipa into Appium Inspector which is an automation testing tool. There the accessibility labels get concatenated, you can see that in this screenshot:
https://ibb.co/Nxq4Cdh
On further inspection, I have found that on the native side, the functions that are handling the accessibility lables don't receive the accessibility labels set.
Other issues opened on this are:
appium/appium#10654
#21830
React Native version: 0.59.5
Steps To Reproduce
- Add some an accessibleLabel to a view
- Go to the following function located in:
React -> Views -> RCTView -> (NSString *)accessibilityLabel - When the flow of the application gets there, you will see that the function tries to return super.accessibilityLabel but every time that is nil
- The flow then goes into the RCTRecursiveAccessibilityLabel function which receives the self parameter from which then he tries to retrieve the subviews that contain the accessibilityLabels but there is no subview when the function gets to that point.
Describe what you expected to happen:
We expect that the (NSString *)accessibilityLabel
function successfully retrieves the accessibilityLabel and returns it or else the RCTRecursiveAccessibilityLabel
function receives the subviews for the current screen
Snack, code example, or link to a repository:
- (NSString *)accessibilityLabel
{
NSString *label = super.accessibilityLabel;
if (label) {
return label;
}
return RCTRecursiveAccessibilityLabel(self);
}
static NSString *RCTRecursiveAccessibilityLabel(UIView *view)
{
NSMutableString *str = [NSMutableString stringWithString:@""];
for (UIView *subview in view.subviews) {
NSString *label = subview.accessibilityLabel;
if (!label) {
label = RCTRecursiveAccessibilityLabel(subview);
}
if (label && label.length > 0) {
if (str.length > 0) {
[str appendString:@" "];
}
[str appendString:label];
}
}
return str;
}