Skip to content

Commit

Permalink
Fix A11Y for horizontal collection nodes in Texture (#1217)
Browse files Browse the repository at this point in the history
* Fix A11Y for horizontal collection nodes in Texture.

Collections have their own handling in UIKit that we shouldn't mess with. As such no nodes that contain CollectionNodes should ever be treated as AccessibilityContainers.

* Update braces
  • Loading branch information
maicki committed Nov 14, 2018
1 parent 771c068 commit 8029632
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
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];
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

0 comments on commit 8029632

Please sign in to comment.