Skip to content

Commit

Permalink
Make ASEditableTextNode accessible to VoiceOver (#1162)
Browse files Browse the repository at this point in the history
* Make ASEditableTextNode accessible to VoiceOver

* Update CHANGELOG

* Make ASEditableTextNode an accessibility container

* Remove initial fix

* Changelog

* Correct changelog entry

* Remove isAccessibilityElement as it’s a container

* Add isNodeLoaded checks

* Remove Changelog Changes
  • Loading branch information
ay8s authored and maicki committed Nov 10, 2018
1 parent 53368a5 commit fd047d6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Source/ASEditableTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -842,4 +842,38 @@ - (void)_delegateDidFinishEditing
[_delegate editableTextNodeDidFinishEditing:self];
}

#pragma mark - UIAccessibilityContainer

- (NSInteger)accessibilityElementCount
{
if (!self.isNodeLoaded) {
ASDisplayNodeFailAssert(@"Cannot access accessibilityElementCount since ASEditableTextNode is not loaded");
return 0;
}
return 1;
}

- (NSArray *)accessibilityElements
{
if (!self.isNodeLoaded) {
ASDisplayNodeFailAssert(@"Cannot access accessibilityElements since ASEditableTextNode is not loaded");
return @[];
}
return @[self.textView];
}

- (id)accessibilityElementAtIndex:(NSInteger)index
{
if (!self.isNodeLoaded) {
ASDisplayNodeFailAssert(@"Cannot access accessibilityElementAtIndex: since ASEditableTextNode is not loaded");
return nil;
}
return self.textView;
}

- (NSInteger)indexOfAccessibilityElement:(id)element
{
return 0;
}

@end

0 comments on commit fd047d6

Please sign in to comment.