Skip to content

Commit 4e37d37

Browse files
sherginfacebook-github-bot
authored andcommitted
Fixed accesibility problem with <TextInput>'s Clear Button
Summary: UITextView is accessible by default (some nested views are) and disabling that is not supported. The problem happened because JS side sets `isAccessible` flag for UITextView and UITextField to `true` (with good intent!), which actually disables (surprise!) bult-in accessibility of TextInput on iOS. On iOS accessible elements cannot be nested, so enabling accessibily for some container view (even in a case where this is view is a public API of TextInput on iOS) shadows some features implemented inside the component. (Disabling accessibility of TextInput via `accessible=false` was never supported.) Reviewed By: JoshuaGross Differential Revision: D15280667 fbshipit-source-id: 72509b40383db6ef66c4263bd920f5ee56a42fc1
1 parent 078f14c commit 4e37d37

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Libraries/Text/TextInput/Multiline/RCTUITextView.m

+9
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ - (void)dealloc
5858
[[NSNotificationCenter defaultCenter] removeObserver:self];
5959
}
6060

61+
#pragma mark - Accessibility
62+
63+
- (void)setIsAccessibilityElement:(BOOL)isAccessibilityElement
64+
{
65+
// UITextView is accessible by default (some nested views are) and disabling that is not supported.
66+
// On iOS accessible elements cannot be nested, therefore enabling accessibility for some container view
67+
// (even in a case where this view is a part of public API of TextInput on iOS) shadows some features implemented inside the component.
68+
}
69+
6170
- (NSString *)accessibilityLabel
6271
{
6372
NSMutableString *accessibilityLabel = [NSMutableString new];

Libraries/Text/TextInput/Singleline/RCTUITextField.m

+9
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ - (void)_textDidChange
4343
_textWasPasted = NO;
4444
}
4545

46+
#pragma mark - Accessibility
47+
48+
- (void)setIsAccessibilityElement:(BOOL)isAccessibilityElement
49+
{
50+
// UITextField is accessible by default (some nested views are) and disabling that is not supported.
51+
// On iOS accessible elements cannot be nested, therefore enabling accessibility for some container view
52+
// (even in a case where this view is a part of public API of TextInput on iOS) shadows some features implemented inside the component.
53+
}
54+
4655
#pragma mark - Properties
4756

4857
- (void)setTextContainerInset:(UIEdgeInsets)textContainerInset

0 commit comments

Comments
 (0)