Skip to content

Commit faaeb77

Browse files
Andrei Shikovfacebook-github-bot
Andrei Shikov
authored andcommitted
Parse accessibilityAction props into object
Summary: Android was using rawProps received from JS, so no updates needed. Updated iOS callsite to use the name of the action. Changelog: [General][Fixed] - Parse accessibilityAction props into object instead of string Reviewed By: mdvacca Differential Revision: D28614407 fbshipit-source-id: 209134f8fac65ca8516039e10ea502e57d52a7a7
1 parent dd96555 commit faaeb77

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ - (BOOL)shouldGroupAccessibilityChildren
630630
NSMutableArray<UIAccessibilityCustomAction *> *customActions = [NSMutableArray array];
631631
for (auto const &accessibilityAction : accessibilityActions) {
632632
[customActions
633-
addObject:[[UIAccessibilityCustomAction alloc] initWithName:RCTNSStringFromString(accessibilityAction)
633+
addObject:[[UIAccessibilityCustomAction alloc] initWithName:RCTNSStringFromString(accessibilityAction.name)
634634
target:self
635635
selector:@selector(didActivateAccessibilityCustomAction:)]];
636636
}

ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h

+7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
#pragma once
99

10+
#include <better/optional.h>
1011
#include <cinttypes>
12+
#include <string>
1113

1214
namespace facebook {
1315
namespace react {
@@ -45,6 +47,11 @@ constexpr enum AccessibilityTraits operator&(
4547
return (enum AccessibilityTraits)((uint32_t)lhs & (uint32_t)rhs);
4648
}
4749

50+
struct AccessibilityAction {
51+
std::string name{""};
52+
better::optional<std::string> label{};
53+
};
54+
4855
struct AccessibilityState {
4956
bool disabled{false};
5057
bool selected{false};

ReactCommon/react/renderer/components/view/AccessibilityProps.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AccessibilityProps {
2929
AccessibilityState accessibilityState;
3030
std::string accessibilityLabel{""};
3131
std::string accessibilityHint{""};
32-
std::vector<std::string> accessibilityActions{};
32+
std::vector<AccessibilityAction> accessibilityActions{};
3333
bool accessibilityViewIsModal{false};
3434
bool accessibilityElementsHidden{false};
3535
bool accessibilityIgnoresInvertColors{false};

ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h

+17
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,22 @@ inline void fromRawValue(
192192
}
193193
}
194194

195+
inline void fromRawValue(const RawValue &value, AccessibilityAction &result) {
196+
auto map = (better::map<std::string, RawValue>)value;
197+
198+
auto name = map.find("name");
199+
react_native_assert(name != map.end() && name->second.hasType<std::string>());
200+
if (name != map.end()) {
201+
fromRawValue(name->second, result.name);
202+
}
203+
204+
auto label = map.find("label");
205+
if (label != map.end()) {
206+
if (label->second.hasType<std::string>()) {
207+
result.label = (std::string)label->second;
208+
}
209+
}
210+
}
211+
195212
} // namespace react
196213
} // namespace facebook

0 commit comments

Comments
 (0)