From 7815f3cabee00a76b7f52b41159018c3e188bdb5 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Fri, 22 Jul 2022 08:44:53 -0700 Subject: [PATCH] Fix VoiceOver for single-line TextInput (#1271) 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` Co-authored-by: Scott Kyle --- 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