Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix A11Y for horizontal collection nodes in Texture #1217

Merged
merged 2 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2390,4 +2390,12 @@ - (void)setPrefetchingEnabled:(BOOL)prefetchingEnabled
return;
}

#pragma mark - Accessibility overrides

- (NSArray *)accessibilityElements
{
[self waitUntilAllUpdatesAreCommitted];
return [super accessibilityElements];
}

@end
8 changes: 8 additions & 0 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1969,4 +1969,12 @@ - (void)didMoveToSuperview
}
}

#pragma mark - Accessibility overrides

- (NSArray *)accessibilityElements
{
[self waitUntilAllUpdatesAreCommitted];
Copy link
Member

@nguyenhuy nguyenhuy Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not familiar with accessbility and not sure when this method is called, but are you sure we want to block the (main?) thread in this case? Would it be better to somehow trigger an accessibility elements recollection once the table/collection finishes its updates?

return [super accessibilityElements];
}

@end
10 changes: 9 additions & 1 deletion Source/Details/_ASDisplayViewAccessiblity.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@

#import <AsyncDisplayKit/_ASDisplayView.h>
#import <AsyncDisplayKit/ASAvailability.h>
#import <AsyncDisplayKit/ASCollectionNode.h>
#import <AsyncDisplayKit/ASDisplayNodeExtras.h>
#import <AsyncDisplayKit/ASDisplayNode+FrameworkPrivate.h>
#import <AsyncDisplayKit/ASDisplayNode+Beta.h>
#import <AsyncDisplayKit/ASDisplayNodeInternal.h>
#import <AsyncDisplayKit/ASTableNode.h>

#import <queue>

Expand Down Expand Up @@ -208,7 +210,13 @@ static void CollectAccessibilityElementsForView(UIView *view, NSMutableArray *el

ASDisplayNode *node = view.asyncdisplaykit_node;

if (node.isAccessibilityContainer) {
BOOL anySubNodeIsCollection = (nil != ASDisplayNodeFindFirstNode(node,
^BOOL(ASDisplayNode *nodeToCheck) {
return ASDynamicCast(nodeToCheck, ASCollectionNode) != nil ||
ASDynamicCast(nodeToCheck, ASTableNode) != nil;
}));

if (node.isAccessibilityContainer && !anySubNodeIsCollection) {
CollectAccessibilityElementsForContainer(node, view, elements);
return;
}
Expand Down