Skip to content

Commit c4c6204

Browse files
ZHUANGPPfacebook-github-bot
authored andcommitted
Add accessibilityRole to RCTAttributedTextUtils
Summary: Changelog: [Internal] - Add `accessibilityRole` to `RCTAttributedTextUtils`. AccessibilityRole was in `TextAttributes` which is a Fabric's abstraction so cannot be detected when enumerating attributedString. Mapping accessibilityRole from `TextAttributes` to `NSAttributedString` could provide the attributeName when iterating over attributedString and then successfully find the range of the fragment whose `accessibilityRole` has value @"link". Reviewed By: shergin Differential Revision: D22286747 fbshipit-source-id: eb039d6a35e77d1860f86ba287391ccb56fbe7b5
1 parent 96708d5 commit c4c6204

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ReactCommon/fabric/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1515

1616
NSString *const RCTAttributedStringIsHighlightedAttributeName = @"IsHighlighted";
1717
NSString *const RCTAttributedStringEventEmitterKey = @"EventEmitter";
18+
NSString *const RCTTextAttributesAccessibilityRoleAttributeName = @"AccessibilityRole";
1819

1920
/*
2021
* Creates `NSTextAttributes` from given `facebook::react::TextAttributes`

ReactCommon/fabric/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
212212
attributes[RCTAttributedStringIsHighlightedAttributeName] = @YES;
213213
}
214214

215+
if (!textAttributes.accessibilityRole.empty()) {
216+
attributes[RCTTextAttributesAccessibilityRoleAttributeName] =
217+
[NSString stringWithCString:textAttributes.accessibilityRole.c_str() encoding:NSUTF8StringEncoding];
218+
}
219+
215220
return [attributes copy];
216221
}
217222

0 commit comments

Comments
 (0)