From 0c25f19d3944e866fcbb6a09da6a55878f739742 Mon Sep 17 00:00:00 2001 From: Carmen Krol Date: Mon, 28 Aug 2023 14:05:14 -0700 Subject: [PATCH] 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 --- .../Mounting/ComponentViews/View/RCTViewComponentView.mm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index b15f9dfb1be..f5490e09703 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -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:@", "]; }