Include accessibilityValue prop values in accessibilityValue (#39184)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39184

Previously, when `props.accessibilityValue` was enabled and other props were enabled, like `props.accessibilityRole`, that are used in the accessibilityValue for iOS, the value from `props.accessibilityValue` wasn't announced.

This is a problem for cases like radio button, which also needs to announce the placement of the radio button within a group, e.g. "[label], radio button, checked, 1 out of 3".

This diff fixes this problem by including the value from `props.acessibilityValue` within the method that builds the `accessibiityValue` for VoiceOver.

Reviewed By: cipolleschi

Differential Revision: D48534155

fbshipit-source-id: 176ba76ff772741a5cdc7d2a56c6cdfb92674477
This commit is contained in:
Carmen Krol
2023-08-28 14:05:14 -07:00
committed by Facebook GitHub Bot
parent ef7ab56c34
commit 0c25f19d39
@@ -766,6 +766,13 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view)
[valueComponents addObject:RCTLocalizedString("busy", "an element currently being updated or modified")];
}
// Using super.accessibilityValue:
// 1. to access the value that is set to accessibilityValue in updateProps
// 2. can't access from self.accessibilityElement because it resolves to self
if (super.accessibilityValue) {
[valueComponents addObject:super.accessibilityValue];
}
if (valueComponents.count > 0) {
return [valueComponents componentsJoinedByString:@", "];
}