Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ @implementation RCTViewComponentView {
UIView *_containerView;
BOOL _useCustomContainerView;
NSMutableSet<NSString *> *_accessibilityOrderNativeIDs;
NSMutableArray<NSObject *> *_accessibilityElements;
RCTViewAccessibilityElement *_axElementDescribingSelf;
}

Expand Down Expand Up @@ -403,6 +404,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
for (const std::string &childId : newViewProps.accessibilityOrder) {
[_accessibilityOrderNativeIDs addObject:RCTNSStringFromString(childId)];
}

_accessibilityElements = [NSMutableArray new];
}

// `accessibilityTraits`
Expand Down Expand Up @@ -614,6 +617,7 @@ - (void)prepareForRecycle
_isJSResponder = NO;
_removeClippedSubviews = NO;
_reactSubviews = [NSMutableArray new];
_accessibilityElements = [NSMutableArray new];
}

- (void)setPropKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN:(NSSet<NSString *> *_Nullable)props
Expand Down Expand Up @@ -1151,13 +1155,19 @@ - (NSObject *)accessibilityElement
return super.accessibilityElements;
}

// TODO: Currently this ignores changes to descendant nativeID's. While that should rarely, if ever happen, it's an
// edge case we should address. Currently this fixes some app deaths so landing this without addressing that edge case
// for now.
if ([_accessibilityElements count] > 0) {
return _accessibilityElements;
}

NSMutableDictionary<NSString *, UIView *> *nativeIdToView = [NSMutableDictionary new];

[RCTViewComponentView collectAccessibilityElements:self
intoDictionary:nativeIdToView
nativeIds:_accessibilityOrderNativeIDs];

NSMutableArray<NSObject *> *elements = [NSMutableArray new];
for (auto childId : _props->accessibilityOrder) {
NSString *nsStringChildId = RCTNSStringFromString(childId);
// Special case to allow for self-referencing with accessibilityOrder
Expand All @@ -1166,16 +1176,16 @@ - (NSObject *)accessibilityElement
_axElementDescribingSelf = [[RCTViewAccessibilityElement alloc] initWithView:self];
}
_axElementDescribingSelf.isAccessibilityElement = [super isAccessibilityElement];
[elements addObject:_axElementDescribingSelf];
[_accessibilityElements addObject:_axElementDescribingSelf];
} else {
UIView *viewWithMatchingNativeId = [nativeIdToView objectForKey:nsStringChildId];
if (viewWithMatchingNativeId) {
[elements addObject:viewWithMatchingNativeId];
[_accessibilityElements addObject:viewWithMatchingNativeId];
}
}
}

return elements;
return _accessibilityElements;
}

+ (void)collectAccessibilityElements:(UIView *)view
Expand Down
Loading