From 4b5f4baebfe37db28004688773f4d11d76b4f42c Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Wed, 12 May 2021 20:42:24 -0700 Subject: [PATCH] Fix VoiceOver for single-line TextInput This adds the appropriate override for AppKit (`setAccessibilityElement:`) so that the `NSTextField` will not get set to be accessible, since its cell instead is already accessible and performs the correct VoiceOver behaviors. VoiceOver now reads as you type in a single-line `TextInput` --- Libraries/Text/TextInput/Singleline/RCTUITextField.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Text/TextInput/Singleline/RCTUITextField.m b/Libraries/Text/TextInput/Singleline/RCTUITextField.m index d84cb8e8f89672..c57db702ac5b6e 100644 --- a/Libraries/Text/TextInput/Singleline/RCTUITextField.m +++ b/Libraries/Text/TextInput/Singleline/RCTUITextField.m @@ -105,7 +105,6 @@ - (instancetype)initWithFrame:(CGRect)frame #if TARGET_OS_OSX // [TODO(macOS GH#774) [self setBordered:NO]; [self setAllowsEditingTextAttributes:YES]; - [self setAccessibilityRole:NSAccessibilityTextFieldRole]; [self setBackgroundColor:[NSColor clearColor]]; #endif // ]TODO(macOS GH#774) @@ -127,7 +126,11 @@ - (void)_textDidChange #pragma mark - Accessibility +#if !TARGET_OS_OSX // [TODO(macOS GH#774) - (void)setIsAccessibilityElement:(BOOL)isAccessibilityElement +#else +- (void)setAccessibilityElement:(BOOL)isAccessibilityElement +#endif // ]TODO(macOS GH#774) { // UITextField is accessible by default (some nested views are) and disabling that is not supported. // On iOS accessible elements cannot be nested, therefore enabling accessibility for some container view